$ git clone https://github.com/kdsuneraavinash/express-ts-api-templateMake sure you have yarn installed.(https://yarnpkg.com/)
Then Run yarn to install dependencies.
$ yarnCopy the .env.example file to .env file and change the values according to your environment.
Install postgres and setup it according to your OS instructions. Use following
command to login to the psql shell.
$ psql -U postgresThen enter below commands.
CREATE ROLE db_user WITH LOGIN PASSWORD 'password';
CREATE
DATABASE example_db;
GRANT ALL PRIVILEGES ON DATABASE
example_db TO db_user;
\qThen login to psql as db_user and check if the setup is done correctly. Password should be password.
psql -U db_user example_db
- Install postgresql in the local machine and setup correctly. Do not change default
port or other settings. Give a password to
postgresuser when asked. - Login to
pgAdminusing the username and password give in the setup process. From theBrowserpanel, selectServer>postgres>Login/Group Rolesand right click and create the role. Givedb_useras role name and givepasswordas the password. - Then right click
Server>postgres>Databasesand Create new database. Giveexample_dbas the database name and setdb_useras the owner. - Then try to login to
psqlshell using default port, server, databaseexample_dbanddb_useruser.
First run the database migration and create the necessary tables. Make sure you are in the correct virtual environment. Whenever there is a database model change, you should re-run this.
$ npx prisma migrate devThen add the initial seed data.
$ npx prisma db seedThe default url for the API is http://127.0.0.1:8000/
$ yarn dev