# Server side init flow

### Step 1

```
$ mkdir server
$ touch server/index.js
$ npm init -y
$ npm install express --save
$ node server/index.js
$ npm install --save-dev babel-cli babel-preset-env
```

index.js

```javascript
import express from 'express';
let app = express();
app.get('/', (req, res) => { res.send('hello world'); })
app.listen(6060, () => console.log('Running on localhost:6060'));
```

### Step 2

```
$ touch .babelrc
```

.babelrc

```
{
  "presets": ["env"]
}
```

package.json

```
"scripts": {
    "start": "nodemon --watch server --exec babel-node -- server/index.js"
  }
```

### Step 3

```
$ mkdir server/routes
$ touch server/routes/users.js
```

users.js

```
import express from 'express'

let router = express.Router()

router.get('/',(req,res)=>{
  console.log('get success')
})

router.post('/',(req,res)=>{
  console.log('post success')
})

export default router
```

index.js

```
import express from 'express';
import users from './routes/users'

let app = express();

app.use('/api/users', users)

app.get('/', (req, res) => {
  res.send('hello world');
})

app.listen(6060, () => console.log('Running on localhost:6060'));
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ke-ren.gitbook.io/web-design/back-end/back-end-index/server-side-init-flow.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
