## macOS 开发环境 - https://deno.land/ A secure runtime for JavaScript and TypeScript. deno今年5月发布正式版本,生态虽说还不是很完善,但本地无`node_modules`的感觉很清爽。 作为mock server很不错。 ```sh # 1. Install deno & postsql brew install deno brew install postsql # 2. config psql # modify postgresql.conf code -r /usr/local/var/postgres/postgresql.conf >> uncomment port=5432 >> uncomment listen_addresses = 'localhost' # Start DB Service brew services start postgresql # Create user postgres & database lvh psql postgres # db login >> create user postgres SUPERUSER; psql postgres # user login >> create database lvh owner=postgres ``` Vscode Plugin: deno - `deno run https://deno.land/std/examples/welcome.ts` - `deno run --allow-net --allow-env server.ts` Hot realod | denon ```sh # Install deno install --allow-read --allow-run --allow-write -f --unstable https://deno.land/x/denon/denon.ts # Export Path to .zprofile or .bash_profile export PATH="/Users/macbook/.deno/bin:$PATH" # Usage denon run --allow-net --allow-env server.ts ``` ## deploy [How to deploy Deno applications to production](https://blog.logrocket.com/how-to-deploy-deno-applications-to-production/) ## steps 1. spreadsheet设计书,图旁边标注出字段名 2. vscode Rest Client 创建 `{resource}.http` -----deno mock 3. add Interfaces in `types.ts` ```ts // common user_id: string; status: number; created_at: Date; updated_at: Date; ``` 2. add controller under `controllers` ## issues CORS: ```typescript import { oakCors } from "https://deno.land/x/cors/mod.ts"; app.use(oakCors()); ``` ## src - [olivewind/awesome-deno-cn](https://github.com/olivewind/awesome-deno-cn) 一份精心编辑的 Deno 相关清单。 - [pogp | Server framework for Deno](https://github.com/sholladay/pogo) - [Deno REST API](https://github.com/bradtraversy/deno-rest-api) 油管教程: [link](https://www.youtube.com/watch?v=NHHhiqwcfRM) ## 生产环境问题 迫不及待部署到了生产环境。 然而出现了很尴尬的情况....deno跑的api在短期内多次出现掉线情况。 看了下服务器负载也没问题,虽说pm2重启一下就好了。 做mock api不错,不过生产环境看来还需要谨慎了。 也许有时间可以看看这里[《Deno进阶开发笔记》](https://github.com/chenshenhai/deno_note)