Skip to content

Instantly share code, notes, and snippets.

@zibellon
Created September 3, 2021 14:22
Show Gist options
  • Save zibellon/bee1c2289c03114d4cf579c8a994aecf to your computer and use it in GitHub Desktop.
Save zibellon/bee1c2289c03114d4cf579c8a994aecf to your computer and use it in GitHub Desktop.
Server first lesson
const express = require('express');
const http = require('http');
const cors = require('cors');
const app = express();
app.use(cors());
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
app.use((req, res, next) => {
console.log('URL = ', req.url);
console.log('Original_URL = ', req.originalUrl);
console.log('METHOD = ', req.method);
console.log('HOST = ', req.headers.host);
console.log('IsSecure = ', req.secure);
console.log('BODY', req.body);
console.log('QUERY', req.query);
next();
});
app.all('/test', (req, res) => {
res.status(200).json({ message: 'KKKKKK'});
})
http.createServer(app).listen(3000, () => {
console.log('Server is working on port 3000');
})
@GoodChoice1
Copy link

жизнекрад через лес очень классно

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment