
Product
Introducing Rust Support in Socket
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.
create-expg-server
Advanced tools
A CLI tool to quickly scaffold an Express.js app with PostgreSQL and Jest.
A CLI tool to quickly scaffold an Express.js app with PostgreSQL and Jest.
To install this package globally, run:
npm install -g create-expg-server
After installation, you can create a new Express app by running:
npx create-expg-server <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>/create-expg-server.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 app with PostgreSQL and Jest.
The npm package create-expg-server receives a total of 0 weekly downloads. As such, create-expg-server popularity was classified as not popular.
We found that create-expg-server 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.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.
Product
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
Product
Socket is launching experimental protection for Chrome extensions, scanning for malware and risky permissions to prevent silent supply chain attacks.