Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

mongoose typescript npm

npm i mongoose-typescript

//app.ts


import * as express from 'express'
import * as mongoose from 'mongoose'

const app = express()

const PORT = 8080

// THIS STRING IS THE LINK TO OUR MONGODB
const url = 'mongodb://localhost:27017/test'

// mongodb connection
mongoose.connect(url, {useNewUrlParser: true, useUnifiedTopology: true, useCreateIndex: true})
.then(result => app.listen(PORT, () => console.log(`app running on port ${PORT}`)))
.catch(err => console.log(err))


app.get('/', (req: express.Request, res: express.Response) => {
    res.setHeader('Content-Type', 'text/html')
    res.end('<h1>Hello World</h1>')
})

app.listen(PORT, () => console.log(`app running on port ${PORT}`))
Comment

PREVIOUS NEXT
Code Example
Typescript :: iframe redirects to another page 
Typescript :: init empty object typescript 
Typescript :: sort two lists that refence each other 
Typescript :: sql check exists stored procedure 
Typescript :: ionic 4 reset form 
Typescript :: @react-navigation/native route typescript 
Typescript :: npm dotenv typescript 
Typescript :: get string in brackets python 
Typescript :: typescript ge t current screen resolution 
Typescript :: react typescript onclick type 
Typescript :: import js file in typescript 
Typescript :: how to call a export constants in nodejs 
Typescript :: linux host file location 
Typescript :: mongo count elements in array 
Typescript :: angular append array to another 
Typescript :: how to check is null or empty in typescript 
Typescript :: what does virtual assistants do? 
Typescript :: mongodb match multiple nested 
Typescript :: actionscript 
Typescript :: react scripts version for react 17.0.2 
Typescript :: emotion/css 
Typescript :: ts react props type 
Typescript :: js Validating nested objects 
Typescript :: angular currency pipe pt-br as variable 
Typescript :: typescript decorators 
Typescript :: check if column exists in dataframe python 
Typescript :: how to clear known_hosts in ssh 
Typescript :: define typescript types 
Typescript :: check if file exists on s3 python 
Typescript :: Parameter type from function TypeScript 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =