This commit is contained in:
Kfir Dayan 2023-04-26 21:01:49 +03:00
parent 6b68ff1f22
commit c6bc89ee2c
2 changed files with 17 additions and 36 deletions

View file

@ -1,41 +1,21 @@
# DropIt Example Project #
examples - Delivery System using Nodejs [Typescript], Express, axios, knex, pg (not implemented yet), in-memory caching.
POST localhost:3000/resolve-address ## Installation
{
"searchTerm": "38%20Upper%20Montagu%20Street%2C%20London%20W1H%201LJ%2C%20United%20Kingdom"
}
install pg MacOS -
Install Homebrew -
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Install Postgres -
brew install postgresql
Start Postgres - ### Git ###
brew services start postgresql clone the project and run `npm install` to install all the dependencies.
Postgres CLI -
psql postgres
init POSTGRES Database - ### typescript - ###
CREATE DATABASE drop_shopping; run `tsc` to compile the typescript files to javascript.
or
run `npm run build` to compile the typescript files to javascript.
create tables - ### Server ###
CREATE TABLE deliveries ( run `npm run dev` to start the server in development mode.
id SERIAL PRIMARY KEY,
user_id INTEGER NOT NULL,
slot_id INTEGER NOT NULL,
delivery_date DATE NOT NULL,
address TEXT NOT NULL,
status VARCHAR(10) NOT NULL
);
### Database ###
knex for migration files run `npm run migrate` to create the database tables.
npx knex migrate:make create_addresses_table run `npm run seed` to seed the database with some data.
npx knex migrate:latest --env development
npx knex migrate:rollback --env development

View file

@ -5,7 +5,8 @@
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1", "test": "echo \"Error: no test specified\" && exit 1",
"dev": "nodemon dist/index.js" "dev": "nodemon dist/index.js",
"build": "npx tsc"
}, },
"keywords": [], "keywords": [],
"author": "", "author": "",