Security News
PyPIβs New Archival Feature Closes a Major Security Gap
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
Welcome to pgcrudapi! This package automatically generates CRUD APIs for PostgreSQL databases, making development faster and easier than ever before.
pg
To get started, install the package using npm:
npm install pgcrudapi
Define your schema:
const schemaDefinition = {
name: { type: 'VARCHAR(100)', required: true },
price: { type: 'NUMERIC', required: true },
category: { type: 'VARCHAR(50)' },
};
Generate CRUD APIs for PostgreSQL:
const app = generateCrudpg({
dbConfig: {
user: 'your-username',
host: 'localhost',
database: 'your-database',
password: 'your-password',
port: 5432,
},
schemaDefinition,
tableName: 'products',
});
app.listen(3000, () => console.log('Server running on port 3000'));
Here's what you get out-of-the-box:
POST /api/products
β Add a new recordGET /api/products
β Fetch all recordsGET /api/products/:id
β Fetch a single record by IDPUT /api/products/:id
β Update a record by IDDELETE /api/products/:id
β Delete a record by IDDELETE /api/products
β Clear all records from the tableExtend the functionality by adding your own custom routes. You can even use other libraries!
const customRoutes = [
{
method: 'get',
path: '/api/products/discounted',
handler: async (req, res) => {
try {
const result = await pool.query(
`SELECT * FROM products WHERE price < 500`
);
res.status(200).json(result.rows);
} catch (error) {
res.status(500).send(error);
}
},
},
];
With pgcrudapi, you donβt need to manually define tables. Simply provide a schema definition and it will create the table for you!
const schemaDefinition = {
name: { type: 'VARCHAR(100)', required: true },
price: { type: 'NUMERIC', required: true },
category: { type: 'VARCHAR(50)' },
};
Your APIs are equipped with:
GET /api/products?filter={"category":"electronics"}
GET /api/products?sort=price,desc
GET /api/products?limit=10&startAfter=5
This package uses:
This project is licensed under the MIT License.
Sumit
π§ sumitdhonde0@gmail.com
FAQs
A CRUD npm package supporting PostgreSQL.
We found that pgcrudapi 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
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
Research
Security News
Malicious npm package postcss-optimizer delivers BeaverTail malware, targeting developer systems; similarities to past campaigns suggest a North Korean connection.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.