
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
I use this as a bootstrap for quickly getting an API running with PostgreSQL and easier development.
It basically opens a connection pool to PostgreSQL, using pg-promise module.
Has some helper methods for building routes, controllers, and "agents", plus mixing/matching middleware.
To get started, create an index.js file, install pm2 globally, and add a "start" script to your package.json
// package.json
"scripts": {
"start": "pm2-dev run ecosystem.json"
}
// ecosystem.json
{
"apps" : [{
"name" : "anchor api",
"script" : "index.js",
"args" : [],
"watch" : true,
"ignore_watch" : ["node_modules", "logs", ".git"],
"node_args" : [],
"log_file": "logs/debug.log",
"err_file": "logs/error.log",
"out_file": "logs/out.log",
"env": {
"NODE_ENV": "development",
"POSTGRESQL_HOST": "localhost",
"POSTGRESQL_PORT": 5432,
"POSTGRESQL_DB": "your-pg-db-name",
"POSTGRESQL_USER": "pg-user-name",
"POSTGRESQL_PASS": "pg-pass-word",
"PORT": 6789,
"DEBUG": "*"
},
"env_production" : {
"NODE_ENV": "production"
},
"env_staging" : {
"NODE_ENV" : "staging",
"TEST" : true
}
}]
}
// index.js
const Quickoa = require('quickoa/app');
const routes = require('./routes');
const app = new Quickoa();
app.addRoutes(routes);
// routes/index.js
const Route = require('quickoa/route');
const {
findComments,
addComment
} = require('../controllers/api/comments');
const api = new Route({
prefix: '/api'
});
/**
Gathers comments for a post with post_id
GET /api/posts/:post_id/comments
*/
api.addRoute('get', '/posts/:post_id/comments', findComments);
/**
Adds a comment to post with post_id
POST /api/posts/:post_id/comments
*/
api.addRoute('post', '/posts/:post_id/comments', addComment);
module.exports.api = api;
// controllers/api/comments.js
const co = require('co');
const CommentAgent = require('../../agents/comment');
const authenticate = require('../../middlewares/authenticate');
module.exports.findComments = [
authenticate,
findCommentsById
];
module.exports.addComment = [
authenticate,
addCommentToPost
];
async function findCommentsById *() {
}
// agents/comments.js
const Agent = require('quickoa/agent');
const validator = require('../validators/comment')
const serializer = require('../serializers/comment');
const {
db: {
postComments
}
} = require('quickoa/db/repos');
module.exports = new Agent({
serializer,
validator,
repo: postComments
});
// serializers/comment.js
const Serializer = require('quickoa/serializer');
const model = require('../models/comment');
const rootKey = 'comment';
module.exports = new Serializer({ rootKey, model });
FAQs
get koa API + postgres up quickly
We found that quickoa demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.