Skip to content

This repository houses the backend code for a minimalist blog platform. It provides a robust API with two core entities: 'Authors/Users' who create and manage posts. Power your blog with this easy-to-use backend system.

Notifications You must be signed in to change notification settings

leoyassuda/blog-service

Repository files navigation

Blog-Service

An API for serve a backend to manage a simple blog.

Prerequisites

  • NodeJS (v16+)
  • Typescript
  • MongoDB

Tech Stack

Built-in:

Setup

npm install

Create .env file:

cp .env.example .env

💭 Don't forget to fill environments variables in .env file.

Start MongoDB using Docker-Compose:

docker-compose up -d

⚠️ Because this app use Prisma, the MongoDB must be set a replicaSet.

See in docs: Prisma.

Generate schema:

npm run generate
model Post {
  id        String   @id @default(auto()) @map("_id") @db.ObjectId
  text      String
  user      User     @relation(fields: [userId], references: [id])
  userId    String   @db.ObjectId
  createdAt DateTime @default(now())
}

model User {
  id       String @id @default(auto()) @map("_id") @db.ObjectId
  name     String
  nickname String
  posts    Post[]
}

This diagram will be generated:
This diagram will be created in prisma folder.

erDiagram
	User {
		Int id PK  "autoincrement()"
		String email
		String name  "nullable"
	}
	Post {
		Int id PK  "autoincrement()"
		String title
		String content  "nullable"
		Boolean published
		Int authorId FK
	}
	Post }o--|| User : author

Loading

Running

You can running using node scripts or makefile.

⚠️ Remember to set DATABASE URL and PORT in .env file.

Node

Running from source code:

npm run dev

or

npm run watch

Building application:

npm run build

Running from compiled:

npm run start

Makefile

Building image

make build

Starting

make start

Authors

  • Leo Yassuda

About

This repository houses the backend code for a minimalist blog platform. It provides a robust API with two core entities: 'Authors/Users' who create and manage posts. Power your blog with this easy-to-use backend system.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published