Hello World!
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 (see Installation guide)
- Create a file named
main.js
and copy the above program there - Run
node main.js
Then, open http://localhost:8000 in your browser to see the response.