Skip to content

A simple NodeJS blog API using Express, TypeScript and Prisma. (Learning purpose)

Notifications You must be signed in to change notification settings

MikaStark/simple-blog-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Blog API

This si a very simple NodeJS Blog API using TypeScript, Express and Prisma.

Requirements

You need recent Node.js installed in your envrionment (at least version 14).

If you want to use a local database, you have to install MySQL or use Docker and pull a MySQL image

Getting started

Use the node package manager (npm) to install all dependencies

npm install

Running dev server

Before all, you must specify which database will be used. Create a .env file inside prisma/ folder with the following content

DATABASE_URL="mysql://USER:PASSWORD@HOST:PORT/NAME"

Then, execute Prisma migration against your development database.

npx prisma migrate dev

Finally run the dev server

npm run dev

By default, the API will run on port 3000. But if you want to use another, specify it through PORT environment variable.

Build for production

Before all, add a DATABASE_URL environment variable to specify which database your project will use

DATABASE_URL="mysql://USER:PASSWORD@HOST:PORT/NAME"

The, deploy your Prisma migrations to your production/testing database.

npx prisma migrate deploy

Then build the API and run start script

npm run build
npm start

Linting

npm run lint

Health check

Server health can be checked at /.well-known/apollo/server-health

Contributing

If you want to contribute to this project you are very welcome but you must keep in mind some recommendations to keep this project fantastic.

  • This project is powered by TypeScript so you need to be familiar with it and also modern JavaScript coding (at least es2015).
  • You can use the code editor you like but we highly recommend using Visual Studio Code because it come with full TypeScript/JavaScript/Node.js support and it provides a blasting Prisma extension.
  • Coding style is very important to keep this project clean and straightforward. This project come with the following technologies and must be used (even if you choose to not use Visual Studio Code).
  • Do not commit non-essential generated files like type definitions
  • Do not commit .env file
  • Keep this project and it dependencies up-to-date

About

A simple NodeJS blog API using Express, TypeScript and Prisma. (Learning purpose)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published