{"id":23107134,"url":"https://github.com/ahmedsomaa/storefront-api","last_synced_at":"2026-04-07T16:32:17.977Z","repository":{"id":136932889,"uuid":"551644522","full_name":"ahmedsomaa/storefront-api","owner":"ahmedsomaa","description":"A node API for a store built with Typescript \u0026 PostgreSQL.","archived":false,"fork":false,"pushed_at":"2022-10-17T19:26:48.000Z","size":237,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-03T22:42:40.898Z","etag":null,"topics":["database","expressjs","jasmine","nodejs","postgresql","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ahmedsomaa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-14T20:05:07.000Z","updated_at":"2025-01-22T15:48:15.000Z","dependencies_parsed_at":"2024-07-16T02:31:41.083Z","dependency_job_id":null,"html_url":"https://github.com/ahmedsomaa/storefront-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ahmedsomaa/storefront-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmedsomaa%2Fstorefront-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmedsomaa%2Fstorefront-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmedsomaa%2Fstorefront-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmedsomaa%2Fstorefront-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ahmedsomaa","download_url":"https://codeload.github.com/ahmedsomaa/storefront-api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmedsomaa%2Fstorefront-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31520500,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-07T16:28:08.000Z","status":"ssl_error","status_checked_at":"2026-04-07T16:28:06.951Z","response_time":105,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","expressjs","jasmine","nodejs","postgresql","typescript"],"created_at":"2024-12-17T01:12:38.135Z","updated_at":"2026-04-07T16:32:17.956Z","avatar_url":"https://github.com/ahmedsomaa.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Storefront API\n\nA node API for a store built with Typescript \u0026 PostgreSQL.\n\n## Tech Stack\n\n- Node.js Runtime.\n- Express for writing node server;.\n- [pg client](https://node-postgres.com/) for managing database connections \u0026 running queries.\n- [Jasmine](https://jasmine.github.io/) for writing unit tests.\n\n## Architecture\n\n![Project Architecture](./images/arch.jpg)\n\n## Dependecies\n\nYou need the following modules and dependencies installed to run this project:\n\n- Docker for the pdotgresql database container.\n- Node 16 for the backend server to run.\n- npm for managing project dependencies.\n\n## Pre running\n\n- I have added two sql files for data migrations under the [data](./data/) folder; [one](./data/seedup.sql) for seeding\n  the database with initial data, for testing purposes, and the [second one](./data/teardown.sql) for cleaning the\n  database from any data.\n- I also added two node script files under the [scripts](./scripts/) folder; each script would run a data migration sql\n  file on the specified database.\n\n## Run locally\n\n- Run `npm install` to install project dependencies.\n- Rename `.env.example` to `.env` and provide values for the variables. See example configurations below:\n\n  ```bash\n  # Server\n  PORT=3000\n\n  # Environment\n  NODE_ENV=test\n\n  # Database settings\n  POSTGRES_PORT=5432\n  POSTGRES_DB=db_dev\n  POSTGRES_HOST=0.0.0.0\n  POSTGRES_USER=db_user\n  POSTGRES_DB_TEST=db_test\n  POSTGRES_PASSWORD=db_password\n\n  # JWT \u0026 Bcrypt settings\n  SALT=10\n  PEPPER=I-am-beyonce-always\n  SECRET=I-declare-bankruptcy\n  ```\n\n- Run `docker compose up` to get the postgresql container up and ready for development.\n- Access the posgresql instance on the docker container using `psql -U postgres`.\n- Create two databses one for development and one for testing by running `CREATE DATABASE \u003cdatabase_name\u003e`. Make sure\n  to replace `\u003cdatabase_name\u003e` with the database name.\n- Create a new databse role using `CREATE USER \u003cuser\u003e WITH PASSWORD \u003cpassword\u003e`. Make sure to replace both `\u003cuser\u003e` \u0026\n  `\u003cpassword\u003e` with the user name and password you want.\n- Connect to each databse using `\\c \u003cdatabase_name\u003e`. Make sure to replace `\u003cdatabase_name` with the actual value.\n- Grant all permissions on the dev and test databases to the newly created user using\n  `GRANT ALL PRIVILEGES ON DATABASE \u003cdatabase_name\u003e TO \u003cuser\u003e`. Make sure to replace the `\u003cdatabase_name\u003e` and `\u003cuser\u003e`\n  with the actual values.\n- Run the database migrations using `NODE_ENV=\u003cenv\u003e npm run migrate:up`. Replace `\u003cenv\u003e` with the actual value which\n  can be either **test** or **dev**.\n- Run the data migrations using `NODE_ENV=\u003cenv\u003e npm run seed` to seed the database with initial data.\n- Run `npm run dev` to run the development server and run `npm start` to run the production server.\n- Finally, the data migrations inserted two users found below. You can choose any one for authentciation to get a token\n  to use for most of the API endpoints.\n  - email: __mscott@dm.com__, password: **date_mike**\n  - email: __dshrute@dm.com__, password: **battlestar_galactica**\n\n\u003e These users only work for the bcrypt secret provided in the example .env config above\n\n## Unit tests\n\nThe tests for the server is written in Jasmine. I have added two environemnts for database **dev** and **test**, see\n[database.json](./database.json) for more info about each database environment. The steps below show how to run the unit\ntests for the testing database environment. To run it on the **dev** environemnt just set `NODE_ENV` to `dev` like\nthis `NODE_ENV=dev`\n\n- `NODE_ENV=test npm run build` to build the project with the testing database as default.\n- `NODE_ENV=test npm run seed` to seed the testing database with initial data.\n- `NODE_ENV=test npm test` to run unit tests on the testing database.\n- `NODE_ENV=test npm run teardown` to clean up the testing database from any data.\n\n**Important Note**\n\n\u003e The commnads `seed \u0026 teardown` will prompt you to provide the database password.\n\n### Coverage\n\nI have provided 69 unit tests that covers:\n\n- pg database client.\n- each database model.\n- each data model handler.\n\n## Available Scripts\n\n- `dev`: to start the development server\n- `start`: to start the production server\n- `test`: to run jasmine tests on chosen database env\n- `lint`: to run eslint on the project's typescript files\n- `clean`: to remove old build folder before building a new one\n- `lint:fix`: to fix issues identified by eslint\n- `prebuild`: to run `npm run clean`\n- `format`: to run prettier on the project's typescript files\n- `migrate:up` to run database migrations on the chosen database env\n- `migrate:down` to drop the last migration on the chosen database env\n- `seed` to run the [seedup.js](./scripts/seedup.js) to populate the chosen database env with seed data\n- `teardown` to run the [teardown.js](./scripts/teardown.js) to clean the chosen database env from seed and any data\n\n## Available API Endpoints \u0026 Database Schema\n\nSee [REQUIREMENTS.md](./REQUIREMENTS.md) file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahmedsomaa%2Fstorefront-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fahmedsomaa%2Fstorefront-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahmedsomaa%2Fstorefront-api/lists"}