@meteor-it/rocket
v2.4.75
Published
Web framework
Downloads
106
Readme
Meteor.Rocket
Powerfull fullstack web framework
Features
- Routing
- Server Side Rendering
- Preloading data
- Advanced HTTP/2 support with optimizations
- Zarbis integration
Usage example
server/index.ts
import Logger from '@meteor-it/logger';
import NodeReceiver from '@meteor-it/logger/receivers/node';
import XPress from '@meteor-it/xpress';
import { ServerMiddleware } from '@meteor-it/rocket';
import rocket from '../web';
import {readFile, read} from '@meteor-it/fs';
Logger.addReceiver(new NodeReceiver());
const logger = new Logger('WEB');
const xpress = new XPress(logger);
(async () => {
logger.log('Init server');
xpress.use(null, new ServerMiddleware(rocket, { compiledClientDir: `${__dirname}/../client`, compiledServerDir: `${__dirname}` }));
xpress.listenHttp('0.0.0.0', 8080);
xpress.listenHttps('0.0.0.0', 8443, {
key: await readFile(`${__dirname}/../../key.pem`),
cert: await readFile(`${__dirname}/../../cert.pem`)
})
})();
client/index.ts
import { initClient } from '@meteor-it/rocket';
import rocket from '../web';
initClient(rocket);
web/index.ts
import Rocket from '@meteor-it/rocket';
const rocket = new Rocket();
rocket.router.on(null, null, async ctx => {
// drawTarget = element which will be rendered on page finally
ctx.state.drawTarget = h([
'Hello, world!'
]);
});