Before you begin, ensure you have the following software installed on your machine:
- Node.js (v14 or higher)
- pnpm (v6 or higher)
- Docker (if using Docker)
- Git (for cloning the repository)
First, clone the repository to your local machine:
using ssh (preferred)
git clone git@github.com:inix-x/seeds-api.git
cd seeds-apiusing https
git clone https://github.com/inix-x/seeds-api.git
cd seeds-apiThis project uses pnpm for package management. Install all necessary dependencies by running:
pnpm installCreate a .env file in the root directory of your project and add the necessary environment variables. You can use the .env.example file as a template:
cp .env.example .envEdit the .env file to include your specific configuration. Here is an example:
PORT=3000
DB_HOST=localhost
DB_USER=root
DB_PASS=example
Ensure your tsconfig.json is properly set up. The following configuration is a good starting point:
{
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"outDir": "./build",
"rootDir": "./src",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"baseUrl": ".",
"paths": {
"*": ["node_modules/*", "src/types/*"]
}
},
"include": ["src"],
"exclude": ["node_modules"]
}To start the development server with hot-reloading, run:
pnpm devThis will start the server using ts-node-dev and automatically reload on file changes.
To compile the TypeScript code into JavaScript, run:
pnpm buildThis will create a build directory containing the compiled JavaScript files.
To start the built project, run:
pnpm start- Login to docker, see above picture;
docker login -u YOUR_DOCKERHUB_USERNAME -p YOUR_PERSONAL_ACCESS_TOKEN- Pull docker image
docker pull omrgrrdo/seeds_postgres:state_v1_2- Importing data and run docker, using cli/terminal or running from docker desktop
docker run -d -p 5432:5432 --name seeds_container -v postgres-data:/var/lib/postgresql/data omrgrrdo/postgres:state_v1_2
docker cp ./db_backup.dump seeds_container:/tmp/mybackup.dump
docker exec -it seeds_container bash
pg_restore -U postgres -d mydatabase -v /tmp/mybackup.dumpdocker exec -t seeds_container pg_dump -U postgres seeds_database -F c -b -v -f tmp/mybackup.dump
docker cp seeds_container:/tmp/mybackup.dump ./db_backup.dumpIf you want to modify the database
psql -U user -d seeds_database -h localhost