mirror of https://github.com/docker/docs.git
[Issue 12622] Node.js guide - update example code (#15922)
* update server.js code
This commit is contained in:
parent
8ebd41f2f6
commit
ad614f1d2c
|
@ -51,13 +51,29 @@ Okay, now that we have a running MongoDB, let’s update `server.js` to use Mong
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
const ronin = require( 'ronin-server' )
|
const ronin = require( 'ronin-server' )
|
||||||
const mocks = require( 'ronin-mocks' )
|
|
||||||
const database = require( 'ronin-database' )
|
const database = require( 'ronin-database' )
|
||||||
const server = ronin.server()
|
const mocks = require( 'ronin-mocks' )
|
||||||
|
|
||||||
database.connect( process.env.CONNECTIONSTRING )
|
async function main() {
|
||||||
server.use( '/', mocks.server( server.Router(), false, false ) )
|
|
||||||
server.start()
|
try {
|
||||||
|
await database.connect( process.env.CONNECTIONSTRING )
|
||||||
|
|
||||||
|
const server = ronin.server({
|
||||||
|
port: process.env.SERVER_PORT
|
||||||
|
})
|
||||||
|
|
||||||
|
server.use( '/', mocks.server( server.Router()) )
|
||||||
|
|
||||||
|
const result = await server.start()
|
||||||
|
console.info( result )
|
||||||
|
|
||||||
|
} catch( error ) {
|
||||||
|
console.error( error )
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
main()
|
||||||
```
|
```
|
||||||
|
|
||||||
We’ve added the `ronin-database` module and we updated the code to connect to the database and set the in-memory flag to false. We now need to rebuild our image so it contains our changes.
|
We’ve added the `ronin-database` module and we updated the code to connect to the database and set the in-memory flag to false. We now need to rebuild our image so it contains our changes.
|
||||||
|
|
Loading…
Reference in New Issue