Skip to content

This is a basic structure for a Node.js with GraphQL and Sequelize

License

Notifications You must be signed in to change notification settings

fabsoftwareifrs/node-quickstart

Repository files navigation

Quickstart

[🇺🇸 EN |🇧🇷 PT-BR]

This is a basic structure for a Node.js with Sequelize, Apollo, MySQL, webpack, babel, JWT, express and ESLint (standart js).

Setup

Requirements

Is necessary install MySQL and NodeJS before run the project. To do this:

In Windows

In Windows is recomended to use winget cli to install this packages.

winget install -e --id OpenJS.Nodejs
winget install -e --id MariaDB.Server

In Linux

Everything can be installed using your distro package manager, for Debian or Ubuntu would it be:

sudo apt install nodejs npm mariadb-server

Configure your MySQL

After install is really important to configure the initial users and configurations of your database, for this run the following command in your terminal:

mysql_secure_installation

PS: in Linux this command need to be run as root (sudo)

The installation will prompt some questions about your database configuration, read them carefuly and answer them properly, them will have it all set.

Start the project

  1. Clone this repo
git clone https://github.com/fabsoftwareifrs/node-quickstart.git myproject
  1. Enter the project folder and delete the .git directory and create .env
cd myproject
rm -Rf .git
cp .env.example .env
code .env

.env

# API Domínio
URL_API=localhost:4000

# Banco de Dados
DB_HOSTNAME=localhost
DB_NAME=mydatabase
DB_USERNAME=root
DB_PASSWORD=[password you configured on MySQL]

# JWT
AUTH_SECRET=[Anything]

# E-mail
EMAIL_SERVICE=
EMAIL_USER=
EMAIL_PASSWORD=
  1. Setup your database:
mysql -u root -p # enter your root password
MariaDB [(none)]> CREATE DATABASE mydatabase CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
MariaDB [(none)]> exit;
  1. install all dependencies
npm i
  1. Migrate the database:
npx sequelize-cli db:migrate
  1. start the project

Terminal 1:

npm run watch:src

Terminal 2:

npm run watch:dist

go to URL http://localhost:4000/graphql in your browser and if you see GraphQL prompt on it everything is working! Enjoy!

Authors

  • Thyago Salvá - Github
  • Maurício Covolan Rosito - Github
  • Leonardo Alvarenga Pereira - Github
  • Camilo Cunha de Azevedo - Github

License

MIT

About

This is a basic structure for a Node.js with GraphQL and Sequelize

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages