A monorepo containing all library packages, rest-ful API backend server, website implementations.
Project is bootstrapped by using create-turbo
cli.
npx create-turbo@latest
As of this document is first written, the project includes two main applications
- REST API server (NestJS)
- Website (NextJS, 100% client side rendering)
os
- should not matter, only tested on ARM based MacOSnode
- >= version 18docker
- docker runtimepnpm
- as package manager,npm
might work with glitches
# any your working dir
git clone [email protected]:ivan-zynesis/weather-and-traffic.git
cd weather-and-traffic
pnpm install
# start a postgres server
docker-compose -f ./apps/postgres/docker-compose.yml up -d
pnpm dev
# shortly
# REST API server listening to localhost:3001
# website server listening to localhost:3000
TODO
With dev
server running in local, run following command to pull the swagger doc and generate a strongly-typed Axios client.
swagger-codegen generate -i http://localhost:3001/swagger-json -l typescript-axios -o packages/generated-api-client
The generated client package will be updated, fix the overwritten package name in /packages/generated-api-client/package.json
back to @repo/generated-api-client
. Run the build
script (in the same package.json file), the client SDK is now ready
for install in the workspace.
By default (see ./apps/postgres/docker-compose.yml
), the postgres container is using a static volume attached to FS
within /apps/postgres. The container is being used for run tests, generate migration script and serve as localhost app
postgres server. Change the volume's directory to have isolated instance or delete it to create a fresh copy.
rm -rf ./apps/api/postgres/postgres-data
- With postgres container running
# <rootdir>
➜ <rootdir> docker-compose -f ./apps/postgres/docker-compose.yml up -d
- make desired changes to database entities.
- (optional) add newly created entity to
/apps/api/src/database/data-source.ts
if any. - Execute typeorm cli generate script
# <rootdir>/apps/api
➜ pnpm run migration:generate ./src/database/migrations/<NewMigrationFileNameHere>
- Include generated migration into
/apps/api/src/database/migrations/index.ts
export const migrations = [...existings, NewGeneratedMigration.ts];