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

typescript-express-sequelize

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

Introduction

Easily bootstrap your Typescript project with NodeJS + Express + Sequelize ORM. ❤️

Installation

Run one of the command below

npm install
npm install -g yarn
yarn

The build tasks use Gulp tasks runner. Typescript is transpiled to Javascript in the /build directory.This sample use PostgreSQL database but you can easily change it and use your favorite relational database (npm or yarn command) :

npm install --save mysql // For both mysql and mariadb dialects
npm install --save sqlite3
npm install --save tedious // MSSQL

Configure your database

Sequelize configuration and entities can be found in /Src/sqlz directory.

Directory Description
config Your database configuration.
migrations Your database migrations scripts. Keep this files in Javascript and run sequelize db:migrate to migrate your database schema.
models Sequelize entities.

First, define your database schema in config/config.json file.Use Sequelize CLI to initialize your database.

In models/ directory, the index.ts file define the DbConnection interface. When you create a new Sequelize entity, add its reference in this interface to fully use Typescript's superpower !

Run the project

npm start

Your web server is now exposed on http://localhost:3000

GET /api/languages

curl -X GET -H 'Content-Type: application/json' http://localhost:3000/api/languages

POST /api/languages

curl -X POST -H 'Content-Type: application/json' -d '{"label":"French","name":"fr"}' http://localhost:3000/api/languages

GET /api/appusers

curl -X GET -H 'Content-Type: application/json' http://localhost:3000/api/appusers

POST /api/appusers

curl -X POST -H 'Content-Type: application/json' -d '{"email":"foo@bar.com","pwd":"something"}' http://localhost:3000/api/appusers

Build

npm run build

Lint your code before you commit!

In a collaborative project, it's always a pain when you have to work on files not correctly formatted.Now before each commit, yout typescript files are linted based on your tsconfig.json > .editorconfig > tslint.json files.

λ git commit -m "Example precommit"

> husky - npm run -s precommit

25l[14:22:30] Running tasks for src/**/*.ts [started]
[14:22:30] prettify [started]
[14:22:31] prettify [completed]
[14:22:31] git add [started]
[14:22:31] git add [completed]
[14:22:31] Running tasks for src/**/*.ts [completed]
25h25h[master 23c4321] Example precommit
 1 file changed, 1 insertion(+), 1 deletion(-)

By the way you can also run the command with a npm script

npm run prettify

Debug with Typescript and VSCode

Add breakpoints to your Typescript source code and launch in VSCode the "Debug Typescript" task.When you'll access to an endpoint, you will be able to debug directly in your Typescript's files.

Questions and issues

The github issue tracker is only for bug reports and feature requests.

Roadmap

  • Add Sequelize Typescript example with association
  • Manage multiple database configuration with NODE_ENV
  • Add Swagger API Framework
  • 在安装sequelize-typescript过程中遇到的一些坑 注意安装的方法: 当你使用的是npm install sequelize --save安装时默认安装的是sequelize最新版也就是V5以上的版本当你在安装npm install sequelize-typescript --save 时默认安装的是最新版,当你在将ts代码编译成js过程中会报一些关于sequelize-types

  • 介绍 (Introduction) In this article we will discuss what an API is, what it means to be RESTful, and how to implement these using Node.js. The Node.js packages we will be using will be Express for our A

  • sequelize操作数据库踩坑 索引BUG 当你的属性unique: true时,.sync({alter: true})会在每次执行的时候新增索引,建议数据库的属性不变时不使用alter:true。 username: { type: DataTypes.STRING, unique: true, // 当你的属性`unique: true`时,`.sync({alter: true})`

  • /* * @Description: * @Author: 熊成强 * @Date: 2019-07-29 11:47:34 * @LastEditTime: 2019-08-02 11:03:06 * @LastEditors: 熊成强 */ var express = require('express'); var forToken = require('../token');

  • 写在前面的话 对于经常使用node的开发人员来说,每次搭建后台服务,都需要考虑如何建立一个更好的文件结构,而大部分的工作都是重复的,有时候会直接拷贝以前的项目文件,但是需要删除或修改很多东西,而且有很多都不需要的文件,这就很烦恼。 想到像vue-cli那样的脚手架一键生成基础项目模版,那我何不做多个属于自己的项目模版。使用的时候只需要一行命令就可以省去很多劳动力,不仅省时省事,而且可以定制自己想要

 相关资料
  • Hey There! �� �� that ⭐️ button if you like this boilerplate. A boilerplate for Node.js App. This boilerplate is built using Express.js web framework, and is using Typescript Lang for writing the app'

  • express-react-typescript A boilerplate to build web application using Express and React with help of Typescript. It's configured to separate client-side JavaScript and CSS bundles and your files as as

  • Node.js Express API with TypeScript 3 Node.js Express API with TypeScript 3. Supports MongoDB Description This skeleton will help you to build your own Node.js Express Mongodb API using TypeScript 3.

  • Express TypeScript Boilerplate This repo can be used as a starting point for backend development with Nodejs. It comes bundled with Docker and is CI/CD optimized. The development environment uses dock

  • express-graphql-typescript-boilerplate A GraphQL starter kit for building amazing API's in TypeScript and with Express.js framework. This seed repository has a complete GraphQL starter kit written in

  • 我试图使用这个库(express-openid-connect)为身份验证后端提供“简单的设置”,但在从调用对象时,我遇到了一个简单的错误: 当然,我得到了这个错误: 没有重载匹配此调用。 重载4中的1“(Path:PathParams,...Handlers:RequestHandler []):Express”,出现以下错误。 类型“(req:OIDRequest,res:express.re