0.1.1 • Published 5 years ago
rocket-server v0.1.1
Rocket Server
A minimalist, secure web server framework with no dependencies.
Hello world
const app = require('rocket-server')
app.token_required = false
app.get('/hello', (res, req, params) => {
res.render('text', 'hello world')
})
const server = require('http').createServer(app.dispatch)
const port = 3000
server.listen(port, function() {
console.log("Server listening on: http://localhost:%s", port)
})
Getting started with examples
Change into the examples directory and start by running:
node ./hello-world.js
Navigate your browser to to http://localhost:3000/hello
to see the running example.
To run the secure example, start the authentication server and the secure server examples:
node ./simple-auth-server.js &
node ./simple-secure-server.js
Follow these steps to see the example in action:
- Navigate to
http://localhost:3001/hello
to see that your access is denied. - Navigate to
http://localhost:3000/login?name=Bob
to authenticate. - Navigate to
http://localhost:3001/hello
to verify the authentication.