Skip to content

📟 example for typescript, with decorators (routing-controllers and sequelize) also have react webpack mocha chai.

License

Notifications You must be signed in to change notification settings

Jiasm/typescript-example

Repository files navigation

typescript-example

📟 example for typescript, with decorators (routing-controllers and sequelize)

dependence

usage

> npm i
> brew services start mysql
> mysql -u root -p
# 请自行修改config/backend/local.js 中的user、password 以及以下的database
mysql> create database ts_test;
mysql> use ts_test;
mysql> CREATE TABLE `user_info_test` (   `uid` int(11) unsigned NOT NULL AUTO_INCREMENT,   `name` varchar(11) NOT NULL,   `age` int(3) DEFAULT '0',   `gender` int(1) NOT NULL,   PRIMARY KEY (`uid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

> npm run watch-ts
> npm run watch-node

> curl http://127.0.0.1:8888/add/Niko/18/1
> curl http://127.0.0.1:8888/add/Bellic/26/2

> curl http://127.0.0.1:8888/list/          # [{name: Niko, ...}, {name: Bellic, ...}]
> curl http://127.0.0.1:8888/list/filter/1  # [{name: Niko, ...}]

front-end

如果还想看TS在React中的使用,可以这样搞:

> cd client-src
> npm i
> npm run dll
> npm run start
# 在确保上边的node服务是启动的情况下
>  open http://127.0.0.1:8888

run test

本示例存在一些简单的测试用例,可以在服务启动的情况下使用:

npm test

配套的一篇水文

关于React的水文地址

最后一公里 - webpack 与 mocha/chai

About

📟 example for typescript, with decorators (routing-controllers and sequelize) also have react webpack mocha chai.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •