Overview
| features | npm | yarn |
|---|---|---|
| lock file | package-lock.json | yarn.lock |
| using workspaces | supported | supported |
| // after-middleware alternative - 2 | |
| const express = require('express'); | |
| const app = express(); | |
| const beforeMiddleware = function(req, res, next) { | |
| console.log('Before middleware triggered'); | |
| next(); | |
| } |
| // | |
| // SPECIAL LICENSE - PROPRIETARY LICENSE AGREEMENT ONLY | |
| // | |
| // https://github.com/ganeshkbhat/fastprimenumbers | |
| // | |
| /* | |
| PROPRIETARY LICENSE AGREEMENT ONLY | |
| Use for your opensource projects only. If you use it or modify it for your project please spend 2 minutes of your time crediting me | |
| by letting me know by either sending me an email, or logging an issue with subject heading `[User]`, or `star` my project. But |
| const checkEsm = import("check-esm"); | |
| let isesm = checkEsm._isESCode("./isESCode.mjs"); | |
| console.log(isesm); |
| let regex = `import | |
| (?: | |
| ["'\s]* | |
| ([\w*{}\n, ]+) | |
| from\s* | |
| )? | |
| ["'\s]* | |
| ([@\w/_-]+) | |
| ["'\s]* | |
| ;? |
| /** | |
| * Route Template: Config | |
| * Path: ./expressjs.api.config.js | |
| */ | |
| var config = { | |
| "pathRoute": "/main", | |
| "dbConfig": { | |
| "path": "mongodb://localhost:27017/test", | |
| "conf": { | |
| "useNewUrlParser": true, |
| /** | |
| * ExpressJS Template Based Routes | |
| Path: ./ | |
| */ | |
| const path = require('path'); | |
| const fs = require('fs'); | |
| var app = require("express"); | |
| var normalizedPath = require("path").join(__dirname, "routes"); | |
| async function requireFiles(d, r = false, cb = (f) => { app.use(require(path.join(f, "index.js"))); }) { |
| /** | |
| * ExpressJS Template Based Routes | |
| Path: ./ | |
| */ | |
| var app = require("express"); | |
| const mainRoute = require("./templates/main.route.template"); | |
| app.use(mainRoute); | |
| app.all("*", function(req, res, next) { | |
| res.send("Hello World Route Present"); |
| var app = require("express"); | |
| const mainRoute = require("./main.route") | |
| app.use(mainRoute); | |
| app.all("*", function(req, res, next) { | |
| res.send("Hello World Route Present"); | |
| }) | |
| app.listen(8000, function() { |
| function someMiddlewareName(req, res, next) { | |
| console.log("Simple middleware Template"); | |
| next(); | |
| } | |
| module.exports = someMiddlewareName |