Create server/package.json with:

{
  "name": "server",
  "private": true,
  "type": "module",
  "scripts": {
    "start": "node --experimental-strip-types --watch index.ts"
  }
}

Install Logux Server:

  • npm i @logux/server

    Create index.ts with:

    import { Server } from '@logux/server'
    import { SUBPROTOCOL } from '../api/index.js'
    
    const server = new Server(
      Server.loadOptions(process, {
        subprotocol: '1.0.0',
        supports: '1.x',
        fileUrl: import.meta.url
      })
    )
    
    server.auth(async ({ userId, token }) => {
      // Allow only local users until we will have a proper authentication
      return process.env.NODE_ENV === 'development'
    })
    
    server.listen()

    The simple Logux server is ready. You can start it with:

  • npm start

    To stop the server press Command+. on Mac OS X and Ctrl+C on Linux and Windows.

    Look at Node.js API to learn server API.