mojolicious / mojo.js Goto Github PK
View Code? Open in Web Editor NEW:unicorn: The Mojolicious real-time web framework for Node.js
Home Page: https://mojojs.org
License: MIT License
:unicorn: The Mojolicious real-time web framework for Node.js
Home Page: https://mojojs.org
License: MIT License
Feathers.js is its own client which is useful to not only standardize web socket communication, but provide helpers for synchronizing data between client and server. Is this something planned for mojo.js, or already possible, or not happening?
Right now TypeScript support is decent, but there's still a few rough edges. In this issue we can collect problems with types and possible solutions.
Known Issues:
ctx.exception
are not declared on the MojoContext
typeMojoContext
This is almost the very same syntax that Koa.js has, you may consider merging the project or using it and its ecosystem as a reference implementation
router.get('/path/:x', async (ctx, next) => {
console.log(ctx.params.x);
await next;
});
See also,
With the 1.0 release quickly approaching done, it is time to make a list of features we would like to see afterwards.
app.plugin(mountPlugin, {app: fooApp, path: '/prefix'})
)ctx.foo.bar(...)
)Mojo::URL
)ctx.proxyGet()
, ctx.proxyRequest()
)ctx.urlForAsset('foo.js')
returns /static/assets/foo.abcd1234.js
)foo.development.js
)http+unix://...
)http+unix://...
)colorFieldTag
dateFieldTag
datetimeFieldTag
emailFieldTag
fileFieldTag
hiddenFieldTag
labelFor
monthFieldTag
numberFieldTag
passwordFieldTag
rangeFieldTag
searchFieldTag
selectFieldTag
(telFieldTag
textFieldTag
timeFieldTag
urlFieldTag
weekFieldTag
--ts
flag)perl -Mojo -E '...'
equivalent (something better than npx mojo eval -v '...'
?)As both mojo.js and Deno are young projects that have great potential and are (imo) great match, would it be possible to port mojo.js to Deno ecosystem?
Can we get a web socket live chat example with mojojs?
I'm not sure how to broadcast a message to all connected clients.
Add default routes and controllers for /startup
, /liveness
, /readiness
. And some top level functions for control liveness/readiness state (ex app.liveness(true), app.readiness(false)).
The text of the logo appears almost black-on-black in dark mode.
Modern HTML makes it pretty easy to specify an alternate dark-mode image:
https://dev.to/dailydevtips1/light-and-dark-mode-image-in-html-lji
run stop hook after command finished or print list command.
Hi, how to enable cors with mojo.js with just an function like cors() in express.js ?
In this issue i will keep a list of features missing for mojo.js 1.0. The list will change regularly. Volunteers are welcome to propose an implementation. We do not port features directly from Mojolicious, they also have to use JavaScript best practices. It's best to discuss ideas on IRC (#mojo.js
on Libera.Chat), so you don't end up wasting your time.
application/x-www-form-urlencoded
):
client.post('/foo', {form: {a: 'b'}})
in the clientawait ctx.req.form
in the servermultipart/form-data
):
client.post('...', {formData: ...})
, form values and file uploads)await ctx.res.formData()
, form values and file uploads)Last-Modified
/If-Modified-Since
/Etag
supportAccept-Ranges
supportwebsocketOk
, sendOk
, messageOk
, messageOk
, finishOk
)app.newMockContext().someHelper()
workrespondTo
methodredirectTo
(options for status
and maybe some future proofing would be nice)urlFor
methodrenderMaybe
methodrenderToString
methodejs
(maybe as part of the plugin, or maybe as a renderer feature)ejs
(maybe with renderToString
, or native ejs
include)routes
commandget
command (already exists, but needs more HTTP features)gen-lite-app
, gen-full-app
, gen-plugin
(once we have settled on a structure)MOJO_SERVER_DEBUG=1
from Mojolicious (without performance loss if not used)X-Forwarded-For
, X-Forwarded-Proto
)insecure
option for self signed certs)All features will need full test coverage. And make sure that there are no performance regressions. An easy test is:
$ node examples/hello.js server
...
$ wrk -c 100 -d 10s http://127.0.0.1:3000
...
Here were will collect the most commonly requested 3rd party plugins that should be available as mojo-plugin-*
modules on NPM. Everyone is invited to work on them and/or discuss their design on the Forum, on Matrix, or IRC. You can use mojo-plugin-ejs as a template.
We will link to the plugins once they exist, there can be more than one per topic of course.
Hello,
Just wanted to announce that I've published a new module to run mojojs applications inside AWS Lambda.
https://www.npmjs.com/package/mojo-plugin-lambda
It's rough and very basic, but it works for me and a very small application that I've written. Hope it helps others embrace mojojs.
Thanks for mojojs and the brilliant documentation, clear code, examples, and complete documentation (which has been a big help for getting this working (I haven't written JS for over a decade).
Count and store metrics for http/ws/pg/minion, like a total requests/request per sec/duration/query length.
Demo application
/*
* Application demonstrating the various HTTP response variants for debugging
*/
import mojo from '../lib/core.js';
import net from 'net';
const app = mojo();
app.get('/res1', ctx => {
const client = net.createConnection({port: 8124}, () => {
console.log('connected to server!');
});
return ctx.render({text: 'Hello World!'});
});
app.get('/res2', async ctx => {
function myAsyncFunction() {
return new Promise((resolve, reject) => {
const client = net.createConnection({port: 8124}, () => {
console.log('connected to server!');
resolve(client);
});
client.on('error', error => {
reject(error);
});
});
}
await myAsyncFunction();
await ctx.render({text: 'Hello World!'});
});
app.start();
I tried this but I get errors:
{
"type": "module",
"dependencies": {
"@mojojs/core": "^1.5.1"
},
"devDependencies": {
"tap": "^16.3.0"
},
"scripts": {
"test": "tap --no-coverage test/*.js",
"dev": "node ./index.js -l 'http://*:8080",
"start": "MOJO_REVERSE_PROXY=1 node ./index.js daemon -l 'http://*:8080'"
}
}
I'm using an nginx proxy in prod but not dev
I have hook for prettify command names
app.addAppHook('command:before', (app: MojoApp, _args: string[]) => {
app.cli.commands = _.mapKeys(app.cli.commands, (_value, key) => key.replaceAll('_', ':'));
});
but it's not work, because hook start before all command load
Thanks for reply ^_^
I have plugin for database connection. Inside plugin i add stop application hook for closing database connection.
When run node index.js
i get list of commands, but not exit to shell.
When run node index.js routes
i get routes, but not exit to shell.
Commands start application, with plugins, but when command finished, does not stop application properly.
Need run application stop hook after command finished or command list printed.
await ctx.render({ view: 'deals/category', format: 'json'}, { deals });
the category.html.tmpl
is being loaded instead of category.json.tmpl
file.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.