Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
@wearemanic/express-base
Advanced tools
Common/shared configuration for Express & MongoDB.
npm install --save @wearemanic/express-base
import { config } from 'dotenv';
import createApp from '@wearemanic/express-base';
import * as schemas from './schemas/index.js';
config();
createApp({ env: process.env, schemas }).listen(3000)
The following configuration is available:
import { config } from 'dotenv';
import createApp from '@wearemanic/express-base';
import fs from 'fs'
import path from 'path'
import * as url from 'url'
import * as schemas from './schemas/index.js';
config();
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
const options = {
env: process.env,
staticDirectory: path.resolve(__dirname, '../dist'),
apiRoot: '/api',
trustProxy: true,
httpsRedirect: true,
middleware: {
cors: {
origin: '*'
...
},
morgan: {
format: 'combined',
options: { ... }
},
json: {
limit: '50mb',
...
}
},
schemas: { ... }
}
createApp(options).listen(3000)
createApp
accepts a schema definition object (schemas
), which it then uses to dynamically create MongoDB collections for each datatype. After instantiating each collection, it then generates API endpoints for managing them.
import { config } from 'dotenv';
import createApp from '@wearemanic/express-base';
config();
const User = {
name: 'String',
email: 'String',
age: 'Number'
}
const Session = {
user: {
type: 'ObjectId',
ref: 'User'
},
location: 'Mixed'
date: {
type: 'Date',
default: Date.now
}
}
createApp({
env: process.env,
schemas: { User, Session }
}).listen(3000)
The above will generate the following routes:
Collection: USER
GET : `/api/users`
GET : `/api/users/:id`
POST : `/api/users`
PUT : `/api/users/:id`
DELETE : `/api/users/:id`
Collection: SESSION
GET : `/api/sessions`
GET : `/api/sessions/:id`
POST : `/api/sessions`
PUT : `/api/sessions/:id`
DELETE : `/api/sessions/:id`
FAQs
Common/shared configuration for Express.
The npm package @wearemanic/express-base receives a total of 0 weekly downloads. As such, @wearemanic/express-base popularity was classified as not popular.
We found that @wearemanic/express-base demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.