• Stars
    star
    484
  • Rank 90,893 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 3 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🦄 The Mojolicious real-time web framework for Node.js

Coverage Status npm

The Mojolicious real-time web framework for Node.js. Written in TypeScript. Meticulously designed for hypermedia-driven backend web services using all the latest JavaScript features.

If you want to stay up to date on the latest developments join us on Matrix or IRC.

Features

  • 3x faster than Express.js and 15x faster than Mojolicious.
  • A real-time web framework, allowing you to easily grow single file prototypes into well-structured MVC web applications.
    • Powerful out of the box with RESTful routes, WebSockets, plugins, commands, logging, templates, content negotiation, session management, form and JSON validation, testing framework, static file server, cluster mode, CGI detection, first class Unicode support and much more for you to discover.
  • A powerful web development toolkit, that you can use for all kinds of applications, independently of the web framework.
    • High performance HTTP and WebSocket client/server implementation with support for HTTPS/WSS, cookies, redirects, urlencoded/multi-part forms, file uploads, JSON/YAML, HTML/XML, mocking, API testing, HTTP/SOCKS proxies, UNIX domain sockets and gzip compression.
    • HTML/XML parser with CSS selector support.
  • No frontend framework, mojo.js is for the backend.
  • Written in TypeScript, with very clean class and async/await based APIs.
  • Very few dependencies, to avoid supply chain attacks and allow for "Perl-grade" long term support and backwards compatibility.
  • Fresh code based upon decades of experience developing Mojolicious and Catalyst, free and open source.

Installation

All you need is Node.js 16.0.0 (or newer).

$ npm install @mojojs/core

Maybe take a look at our high quality spin-off projects @mojojs/dom, @mojojs/path, @mojojs/pg and @mojojs/template.

Getting Started

These four lines are a whole web application.

import mojo from '@mojojs/core';

const app = mojo();

app.get('/', ctx => ctx.render({text: 'I ♥ Mojo!'}));

app.start();

Use the built-in command system to start your web server.

$ node index.mjs server
[77264] Web application available at http://127.0.0.1:3000/

Test it with any HTTP client you prefer.

$ curl http://127.0.0.1:3000/
I ♥ Mojo!

Duct Tape for the Web

Use all the latest Node.js and HTML features in convenient single file prototypes like this one, and grow them easily into well-structured Model-View-Controller web applications.

import mojo from '@mojojs/core';

const app = mojo();

app.get('/', async ctx => {
  await ctx.render({inline: inlineTemplate});
});

app.websocket('/title', ctx => {
  ctx.plain(async ws => {
    for await (const url of ws) {
      const res   = await ctx.ua.get(url);
      const html  = await res.html();
      const title = html.at('title').text();
      await ws.send(title);
    }
  });
});

app.start();

const inlineTemplate = `
<script>
  const ws = new WebSocket('<%= ctx.urlFor('title') %>');
  ws.onmessage = event => { document.body.innerHTML += event.data };
  ws.onopen    = event => { ws.send('https://mojolicious.org') };
</script>
`;

Want to know more?

Take a look at our excellent documentation!

More Repositories

1

mojo

✨ Mojolicious - Perl real-time web framework
Perl
2,656
star
2

minion

🐙 Perl high performance job queue
Perl
223
star
3

mojo-pg

Mojolicious ❤️ PostgreSQL
Perl
101
star
4

mojolicious.org

🍪 Mojolicious Website
CSS
32
star
5

mojo-assetpack

🚜 Compress and convert CSS, Less, Sass and JavaScript files
Perl
30
star
6

mojo-status

🐳 Mojolicious server status
Perl
29
star
7

Mojo-AsyncAwait

🙀 An Async/Await implementation for Mojolicious
Perl
21
star
8

dom.js

🔮 A fast and very small HTML/XML DOM parser with CSS selectors
JavaScript
20
star
9

pg.js

mojo.js ❤️ PostgreSQL
JavaScript
15
star
10

minion.js

🐎 Node.js high performance job queue
JavaScript
14
star
11

vscode-mojo

🔧 VS Code support for Mojolicious
14
star
12

path.js

🏕️ Convenient container class for file system paths.
TypeScript
12
star
13

template.js

⚡ A very fast embedded JavaScript template engine
JavaScript
11
star
14

server-starter

💫 Superdaemon
JavaScript
8
star
15

sql-abstract-pg

🐘 PostgreSQL features for SQL::Abstract
Perl
5
star
16

mojo-plugin-ejs

🚧 mojo.js plugin example
JavaScript
5
star
17

mojo-plugin-nunjucks

🚧 mojo.js plugin example (TypeScript)
TypeScript
3
star
18

mojojs.org

💥 mojo.js website
CSS
3
star
19

create-full-app

🐰 Create a full mojo.js app
JavaScript
3
star
20

sql.js

🏗️ Safely generate SQL statements with tagged template literals
JavaScript
3
star
21

vscode-mojo.js

🎭 VS Code support for mojo.js
2
star
22

create-lite-app

🐭 Create a single file mojo.js app
JavaScript
2
star
23

mojo-plugin-middleware

🪂 Express.js middleware support for mojo.js
1
star
24

user-agent.js

Experimental next gen user-agent
JavaScript
1
star
25

util.js

🔨 Just some utilities
JavaScript
1
star