Skip to main content

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

  1. Initialize Node.js project
  2. Install Lunatic (see Installation guide)
  3. Create a file named main.js and copy the above program there
  4. Run node main.js

Then, open http://localhost:8000 in your browser to see the response.