What do you want to save?
Add Code snippet
New code examples
-
Javascript 2021-11-17 19:14:11
how to connect to mongoose and create a model
const express = require('express'); const app = express(); const mongoose = require('mongoose'); const bodyParser = require('body-parser'); app.use(bodyParser.json()); const PORT = process.env.PORT || 3000; //connecting to db try { mongoose.conne... Add solution -
Javascript 2021-11-17 14:37:20
require database
const express = require('express'); const cors = require('cors'); const superagent = require('superagent'); const pg = require('pg'); require('dotenv').config(); const app = express(); app.use(cors()); app.use(express.static('public')); app.set('view engi... Add solution -
Javascript 2021-11-16 06:16:24
host angular app on node server
const express = require('express'); const http = require('http'); const path = require('path'); const app = express(); const port = process.env.PORT || 3001; app.use(express.static(__dirname + '/dist/my-app-name')); app.get('/*', (req, res) => res.... Add solution -
Javascript 2021-11-14 20:16:18
ssl configuration in node js
const https = require("https"), fs = require("fs"), helmet = require("helmet"); const options = { key: fs.readFileSync("/srv/www/keys/my-site-key.pem"), cert: fs.readFileSync("/srv/www/keys/chain.pem&q... Add solution -
Other 2021-11-14 13:07:14
apollo server-express
npm install apollo-server-express # yarn yarn add apollo-server-express # server.js import express from 'express'; import bodyParser from 'body-parser'; import { graphqlExpress } from 'apollo-server-express'; const myGraphQLSchema = // ... define or i... Add solution -
Javascript 2021-11-14 00:20:24
express load a page
const express = require('express'); const app = express(); const path = require('path'); const router = express.Router(); router.get('/',function(req,res){ res.sendFile(path.join(__dirname, '/index.html')); //__dirname : It will resolve to your proje... Add solution -
Javascript 2021-11-13 20:56:10
create server with express js
// npm init // npm i express const express = require('express'); const server = express(); const PORT = 3000; // Body parser server.use(express.json()); // Homme page server.get('/', (req, res) => { return res.send("<h1 style='text-align:... Add solution -
Javascript 2021-11-11 21:03:13
express get raw query
const url = require('url'); const express = require('express'); const app = express(); app.use((req, res, next) => { const query = url.parse(req.url).query; // Do something... }); const port = 3000; app.listen(port, console.log(`Listening on port... Add solution -
Javascript 2021-11-11 18:44:10
node js express
const express = require('express'); const app = express(); const PORT = process.env.PORT || 3000; app.get('/', (req, res) => { res.send('<h1>Some HTML</h1>'); res.send('<p>Even more HTML</p>'); }); app.listen(PORT, () =>... Add solution