Let's build a full-stack Tik Tok clone with VueJS and NestJS! - Part 1. NestJS Rest API - Setup

rafael_abuawad profile image Rafo AV ・2 min read

📑 Complete series

--> Part 1. NestJS Rest API - Setup
Part 2. NestJS Rest API - DB Entities
... Work in progress

🔥 Getting started

Let's start by creating a folder called 'tik-tok-clone' inside your projects folder. Open the terminal on your projects folder and type the following commands.

$ cd .\projects
$ mkdir tik-tok-clone
$ cd .\tik-tok-clone

Now lest create a new NestJS project, we will call it 'tik-tok-api'.

$ nest new tik-tok-api

We run this command a wait until everything is completed, you might be prompted to choose between yarn or npm, I would recommend sticking with npm.

Once the installation is completed, we move inside the folder (writing $ cd tik-tok-api on your terminal), and open the project in your favorite Text Editor or IDE.

You can delete the test folder and the app.controller.spec.ts file since we won't be covering testing in this tutorial series. Also, we can delete the app.service.ts and the app.controller.ts file and modify the app.module.ts file to look something like this:

// app.module.ts
import { Module } from '@nestjs/common';

  imports: []
export class AppModule {}

📮 Setting up the Database

One of the most important parts of Web API development is the Database, I chose to go with SQLite for this project because it's an easy use SQL Database, and it also is really portable due to the DB living on a single file.

Let's start by installing the NestJS adapter for TypeORM and TypeORM itself on the project, open your terminal, and type the following command. Install it on you tik-tok-api folder, NOT the root.

$ npm install --save @nestjs/typeorm typeorm sqlite3

Once everything is installed, open the app.module.ts file and modify it to look something like this:

// app.module.ts
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';

  imports: [
      type: 'sqlite',
      database: './app.db',
      entities: [],
      synchronize: true,
export class AppModule {}

Here we imported the TypeOrmModule, added it to the imports of the app, and configure it to use an SQLite instance.

Now the basic skeleton of our app is done, in the next chapter we will finish setting up the database, hope to see you there.

Posted on by:


Editor guide