
Security News
Static vs. Runtime Reachability: Insights from Latio’s On the Record Podcast
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.
quick-ex-db-monorepo
Advanced tools
A CLI tool to quickly scaffold an Express.js server with a database
A CLI tool to quickly scaffold an Express.js app with PostgreSQL and Jest.
To install this package globally, run:
npm install -g quick-ex-db
After installation, you can create a new Express app by running:
npx quick-ex-db <project-name>
.env.test
PGDATABASE=your_test_db_name
.env.development
PGDATABASE=your_db_name
Create the first endpoint test in app.test.js:
const request = require("supertest");
const app = require("../app");
describe("GET /endpoint", () => {
it("should respond with 200 status", async () => {
const response = await request(app).get("/endpoint");
expect(response.statusCode).toBe(200);
});
});
Run the test:
npm test
const express = require("express");
const router = express.Router();
const { getExample } = require("../controllers/example-controller.js");
router.get("/example", getExample);
module.exports = router;
const { selectExample } = require("../models/example-model.js");
exports.getExample = (req, res, next) => {
selectExample()
.then((example) => {
res.status(200).send({ example });
})
.catch((err) => {
next(err);
});
};
const db = require("../../db/connection.js");
exports.selectExample = () => {
return db.query("SELECT * FROM example_table").then(({ rows }) => {
return rows;
});
};
createdb <database-name>
copy the URI connection string
- "postgres://...", or keep that tab open as you complete the next step
.Carrying on from before, with the database password and URI both handy:
DATABASE_URL=postgresql://postgres:[YOUR-PASSWORD]@<host>:<port>/postgres
New +
button at the top right.yarn
and the default start command to yarn start
.Environment Variables
section:Key
called DATABASE_URL
using the URI for Value
from your .env.production
fileKey
called NODE_ENV
, set the value
to production
Logs
for it by going to the Events
on the dashboardWhen it's deployed, you can view it via the generated link, upon navigating there you will be greeted with an error, make sure you are pointing to an existing endpoint, such as /api
and confirm your data is being fetched correctly.
I welcome contributions to improve this tool! Here’s how you can help:
If you find a bug or have a feature request, please create an issue on the GitHub repository.
git clone https://github.com/<your-username>/quick-ex-db.git
git checkout -b my-new-feature
git add .
git commit -m "Add my new feature"
git push origin my-new-feature
FAQs
A CLI tool to quickly scaffold an Express.js server with a database
The npm package quick-ex-db-monorepo receives a total of 0 weekly downloads. As such, quick-ex-db-monorepo popularity was classified as not popular.
We found that quick-ex-db-monorepo 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
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.
Security News
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.