Skip to content

Latest commit

 

History

History
53 lines (41 loc) · 1012 Bytes

README.md

File metadata and controls

53 lines (41 loc) · 1012 Bytes

Dash Backend

Starting out

Install necessary dependencies with

npm i

Starting the server

The server starts on port 3000. Start the server with

npm start

Writing endpoints

Write minimal code for endpoints in app.js. Write more logic in individual files in src/.

The generic code for an endpoint is:

app.get('/get-endpoint', (request, response) => {
  /* Simple get request 
    request.body should be in JSON. It is automatically parsed and can be
    accessed like a JS object.
  */
  logic here...
})
app.post('/post-endpoint', (request, response) => {
  /* Simple post request 
    request.body should be in JSON. It is automatically parsed and can be
    accessed like a JS object.
  */
  logic here...
})

Writing logic

Write logic in individual files. Modules are written in the singleton design pattern.

module.exports = {
  object code here...
}

Import them as a singleton object as

const mylogic = require('./src/logic-file.js')