• Latest
Make a Rest API Using Only 2 Commands

Make a Rest API Using Only 2 Commands

December 7, 2021
NieR:Automata For Switch Handled By Nintendo Port Specialist Virtuos

NieR:Automata For Switch Handled By Nintendo Port Specialist Virtuos

July 5, 2022
Here’s what Stage Manager looks like on the iPad mini

Here’s what Stage Manager looks like on the iPad mini

July 5, 2022
Moto G42 launches in India

Moto G42 launches in India

July 5, 2022
PlatinumGames’ Shmup Sol Cresta Receives An Update, Here’s What’s Included

PlatinumGames’ Shmup Sol Cresta Receives An Update, Here’s What’s Included

July 5, 2022
Xbox sale round-up May 10th, 2022

Xbox sale round-up July 5th, 2022

July 5, 2022
How to pick a location with stunning light for family photos

How to pick a location with stunning light for family photos

July 5, 2022
Meta to discontinue ‘Novi’ cryptocurrency digital wallet

Meta to discontinue ‘Novi’ cryptocurrency digital wallet

July 5, 2022
Samsung Galaxy S22 Ultra is expected to outsell the last four Galaxy Notes

Samsung Galaxy S22 Ultra is expected to outsell the last four Galaxy Notes

July 5, 2022
GamerCoins Beta Launches, Hundreds Of Free Game Codes Up Now!

GamerCoins Beta Launches, Hundreds Of Free Game Codes Up Now!

July 5, 2022
Five top-tier cameras that are NSFW (Not Safe For Wallets)

Five top-tier cameras that are NSFW (Not Safe For Wallets)

July 5, 2022
How to change Apple ID

How to change Apple ID

July 5, 2022
Use iMac as monitor: 5 Solutions

Use iMac as monitor: 5 Solutions

July 5, 2022
Advertise with us
Tuesday, July 5, 2022
Bookmarks
  • Login
  • Register
GetUpdated
  • Home
  • Game Updates
    • Mobile Gaming
    • Playstation News
    • Xbox News
    • Switch News
    • MMORPG
    • Game News
    • IGN
    • Retro Gaming
  • Tech News
    • Apple Updates
    • Jailbreak News
    • Mobile News
  • Software Development
  • Photography
  • Contact
    • Advertise With Us
    • About
No Result
View All Result
GetUpdated
No Result
View All Result
GetUpdated
No Result
View All Result
ADVERTISEMENT

Make a Rest API Using Only 2 Commands

December 7, 2021
in Software Development
Reading Time:3 mins read
0 0
0
Share on FacebookShare on WhatsAppShare on Twitter


SuperApiBoost is a client that seeks to improve development times. 

In this post, I will show you how to make a complete API under NodeJs with Typescript, Mongo, and Express with just two commands.

Making a Complete REST API

The first thing you need to do is install the client with npm.

To generate the project, you must execute the “new” command optionally with the -n flag to assign the name. (If you don’t set the name of the project, the client will ask you.)

This will create a root folder with the name of the project and install the dependencies. 

Awesome
 ┣ node_modules
 ┣ src
 ┃ ┣ api
 ┃ ┃ ┣ routes
 ┃ ┃ ┗ index.ts
 ┃ ┣ controllers
 ┃ ┃ ┗ mongoBasic.ts #CRUD Methods
 ┃ ┣ interfaces
 ┃ ┣ tools #utils functions
 ┃ ┃ ┗ validateType.ts
 ┃ ┣ app.ts
 ┃ ┣ config.ts
 ┃ ┗ mongo.ts

As an example, we will create a crud for the following JSON. 

{
  "name":"Andy",
  "cellphone":303030303,
  "isValid":false
}

First, you need to execute the generate command.

They have two flags. Both are optional.

The first is the name -n=[NAME], which is necessary to generate the route and controller.

The second is the -p=[PATH], which is the absolute path to locate the .json file of the model. In this case, we will generate the schema with the client.

// history of the execution
$ sabo generate
$ Write a name for the controller: API
$ You want to create a controller without schema? (Use arrow keys)
$  Yes
$ >No
$ Name of the field: name
$ ? Choose a type (Use arrow keys)
$ >string
$  number
$  boolean
$  array
$ ? Is required? (Use arrow keys)
$ >Yes
$  No
$ ? Add a new field? (Use arrow keys) //Repeat the process with every field of the schema
$ >Yes
$  No

This will create the interface, controller, and routes. If you don’t want to generate the schema, the client will generate only the controller and route with an example method and route.

Go to the config.ts file and assign the connection string of your mongo database.

Execute npm start, and we will be able to consume the API with our preferred client.



Source link

ShareSendTweet
Previous Post

Welcome to Flix Today !

Next Post

The Best Action-Adventure Game of 2021

Related Posts

Understanding OAuth 2.0 – DZone Security

July 4, 2022
0
0
Understanding OAuth 2.0 – DZone Security
Software Development

In a traditional client-server authentication model, a resource owner shares their credentials with the client so that the client can...

Read more

NativeScript vs. Flutter: A Comparison

July 4, 2022
0
0
NativeScript vs. Flutter: A Comparison
Software Development

With the growing demand for lifestyle and communication apps, mobile app development has become a booming industry. Building apps for...

Read more
Next Post
The Best Action-Adventure Game of 2021

The Best Action-Adventure Game of 2021

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

© 2021 GetUpdated – MW.

  • About
  • Advertise
  • Privacy & Policy
  • Terms & Conditions
  • Contact

No Result
View All Result
  • Home
  • Game Updates
    • Mobile Gaming
    • Playstation News
    • Xbox News
    • Switch News
    • MMORPG
    • Game News
    • IGN
    • Retro Gaming
  • Tech News
    • Apple Updates
    • Jailbreak News
    • Mobile News
  • Software Development
  • Photography
  • Contact
    • Advertise With Us
    • About

Welcome Back!

Login to your account below

Forgotten Password? Sign Up

Create New Account!

Fill the forms bellow to register

All fields are required. Log In

Retrieve your password

Please enter your username or email address to reset your password.

Log In
Are you sure want to unlock this post?
Unlock left : 0
Are you sure want to cancel subscription?