当前位置: 首页 > 软件库 > Web应用开发 > >

rest-api-node-ts-boilerplate

授权协议 Readme
开发语言 JavaScript
所属分类 Web应用开发
软件类型 开源软件
地区 不详
投 递 者 白子默
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

RESTful API using Node.js, Express, Mongoose & TypeScript

technologies

This is a boilerplate for building scalable and robust REST APIs using Node.js & TypeScript.

Table of Contents

Prerequisites

You need to install MongoDB either on your local machine or using a cloud service as mLab.

Features

Getting Started

Installation

  1. install the dependencies using npm install or npm i

  2. Rename the file .env.example to .env, then you need to configure the file config.ts located in src/config

  3. Start the app using npm run dev

  4. After that, go to: http://localhost:3000/v1/users

Directory Structure

├── src
│   ├── apiV1
│   │   ├── auth
│   │   │  ├── auth.controller.ts
│   │   │  └── auth.route.ts
│   │   ├── users
│   │   │   ├── user.controller.ts
│   │   │   ├── user.controller.ts
│   │   │   └── user.route.ts
│   │   └── index.ts
│   ├── config
│   │   ├── config.ts
│   │   └── db.ts
│   ├── helpers
│   │   ├── errorHandler.ts
│   │   └── verifyToken.ts
│   ├── .env.example
│   ├── App.ts
│   └── index.ts
├── .editorconfig
├── .gitignore
├── package.json
├── README.md
├── tsconfig.json
└── tslint.json

Available routes

Method Resource Description
POST /register Create a new user in the DB. You need to specify in the body the following attributes: name, lastname, email & password.
POST /authenticate Sign in with the email & password. If it's successful, then generates a token
GET /users Returns the collection of users present in the DB.
GET /users/:id It returns the specified id user. You need to specify the token in the header with the following format: Authorization: Bearer your-token
PUT /users/:id Updates an already created user in the DB
DELETE /users/:id Deletes a user from the DB

Available scripts

  • build - Transpile TypeScript to ES6,
  • lint - Lint your TS code,
  • dev - To run the app without transpile to ES6,
  • clean - Remove dist, node_modules, coverage folders,
  • start - Run the transpiled app
  • prod - Build & run the transpiled app

License

MIT © Michael Méndez

  • 搭建Node TS开发环境 项目结构 npm init -y npm i typescript ts-node-dev tslint @types/node -D npm i sequelize-typescript@0.6.11 npm i sequelize@6.3.3 启动脚本 "scripts": { "start": "ts-node-dev ./src/index.ts -P ts

  • 本文利用nodejs+restify 开发rest api,非express 等rest服务。去除了多余的模板内容。 操作步骤: 1.下载依赖: cnpm install restify restify-plugins restify-errors --save 复制代码 2.hello-world: /** * Module Dependencies */ const config = re

  • //npm install node-rest-client --save-dev var Client = require('node-rest-client').Client function locate() { var client = new Client() var args = { data: { input: "hello" },

  • app.js 'use strict'; console.log('Hello world'); const Koa = require('koa'); const bodyParser = require('koa-bodyparser'); const app = new Koa(); const controller = require('./controller'); // parse

 相关资料
  • Building RESTful Web APIs with Node.js, Express, MongoDB and TypeScript This is a simple API that saves contact information of people. There are two versions of this project. V1.0.0: you can run the s

  • Clean Node API Link para o curso completo Essa API faz parte do treinamento do professor Rodrigo Manguinho (Mango) na Udemy. O objetivo do treinamento é mostrar como criar uma API com uma arquitetura

  • Node - Koa - Typescript Project The main purpose of this repository is to build a good project setup and workflow for writing a Node api rest in TypeScript using KOA and an SQL DB. Koa is a new web fr

  • Node.js API com Typescript Código do curso �� DO ZERO A PRODUÇÃO: APRENDA A CONSTRUIR UMA API NODE.JS COM TYPESCRIPT Durante o curso é criado uma API para calcular a melhor condição de surf entre vari

  • 由于现有的node weixin api接口做的比较麻烦,不利于书写与理解.故重新书写代码,架构. 让开发者更容易理解与使用,并且帮助提升软件质量 node-weixin-api是基于node-weixin-*的API接口的SDK。 它们都是由下列子项目组合而成, node-weixin-api只是将业务接口统一到一个api里方便调用,而不必一个一个重新安装: node-weixin-config

  • 我尝试了很多次,但得到以下错误 http://localhost:3001/getlocaiton net::err_connection_delection和createError(createError.js:17)位于xmlHttpRequest.handleerror(xhr.js:87)。