Hello, World!
Install Lunatic
Install Lunatic with your favorite package manager:
npm i @shelepuginivan/lunaticyarn add @shelepuginivan/lunaticpnpm add @shelepuginivan/lunaticNote that Lunatic requires Node 12.x or higher.
Your first application
import { LunaticServer } from '@shelepuginivan/lunatic'
const app = new LunaticServer()
app.get('/', (req, res) => { res.status(200).json({ hello: 'lunatic' })})
app.listen(8000).then(() => console.log('Server started on port 8000...'))This program starts a server on http://localhost:8000,
which accepts GET / requests. For any other method and path server will
respond with 501 Not Implemented.
How to run
- Initialize Node.js project
- Install Lunatic
- Create a file named
main.jsand copy the above program there - Run
node main.js
Then, open http://localhost:8000 in your browser to see the response.
More examples
There is a separate repository that demonstrates capabilities of Lunatic.