Skip to content

Instantly share code, notes, and snippets.

View josephfinlayson's full-sized avatar

Joseph Finlayson josephfinlayson

View GitHub Profile
//all are /application/json
//Offering an item
// POST request to endpoint /api/postItem
{
itemName: String,
itemPrice: Number,
Description: String,
lockerCode: String,
image: String, //BASE64

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

var Article = require('../../../models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@josephfinlayson
josephfinlayson / read-access.sql
Created August 1, 2019 12:28 — forked from oinopion/read-access.sql
How to create read only user in PostgreSQL
-- Create a group
CREATE ROLE readaccess;
-- Grant access to existing tables
GRANT USAGE ON SCHEMA public TO readaccess;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess;
-- Grant access to future tables
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess;