Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
September 23, 2021 09:36 am GMT

Setting up new project

image

What do you know about solid, kiss and bunch of other things?
Fug them.
When you are writing any kind of code. Just write and see the result. You do not like it? Go change it.

Do not forget one thing, Rome is not built in one day or night

Let`s assume we all have nodejs installed. Create folder named like boilerplate and open that folder in your code editor.

initiate - npm init -y

I like MVC, like a lot. So create bunch of folders such as controllers, models, services, middlewares, database(migrations, seeds), utils

image

Install necessary packages
  • npm install knex -g
  • npm install objection knex mysql --save
  • npm install express dotenv --save

Go grab the code from here
and continue.

First of all check the codebase, if you like it you are more than welcome to use it. If no, what the hell are you doing here then? Go leave my blog. Kidding .

Let me show you some things here:

  • npx knex migrate:make posts - this will create migration file
  • npx knex migrate:latest - this will create tables in your db
  • npx knex migrate:rollback - if you forgot something to add in your latest migration and you change it, try this then you are good to migrate again, without this your terminal spits right in your face.
  • npx knex seed:make posts - this creates file which you can populate with good old friend faker then you can insert it with npx knex seed:run.

Original Link: https://dev.to/ilyosdev/setting-up-new-project-57h8

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To