当前位置:网站首页>Use of KOA framework
Use of KOA framework
2022-07-23 14:51:00 【Bump】
koa Use of framework
2022/7/21
A Study Day
| name | Koa Use of framework |
|---|---|
| author | Bump |
| state | The end |
| brief introduction | How to use it after reading Koa The framework ~ |
Installation command
npm i -g koa-generator
Create project
koa2 -e Project name
Enter the project root directory to execute : npm install
stay package.json Modify the startup command to nodemon
Premise remember to install nodemon Oh …

Cross domain
install
koa2-corsSolving cross domain problems
npm i -S koa2-cors
To configure :
stay app.js Add the following code before introducing the routing configuration
const cors=require('koa2-cors')
app.use(cors({
origin:'*',
allowMethods:['GET','POST','OPTIONS','PUT','DELETE'],
allowHeaders:['authorization','token','Content-Type']
}))
database mysql
install mysql2
npm i -S mysql2
Encapsulated connection pool
Created in the root directory utils/dbpool.js
const mysql=require('mysql2/promise')
const pool=mysql.createPool({
host:'localhost',
port:3306,
database:'dbshop',
user:'root',
password:'123456',
connectionLimit:10
})
module.exports= pool;
Use
Import in a route file dbpool.js that will do , for example
Example
- How to insert records
encryption
adopt crypto To encrypt
- For example, the login registration password is encrypted
Installation dependency
npm i -S crypto
Encryption method
let The encrypted string =crypto.createHmac(‘sha256’, Key string ).update( password ).digest(‘base64’);
for example :
About me
personal Blog Online : Bump Study
边栏推荐
- 关于flex布局justify-content:space-around最后一个不对齐的解决方法和为什么这样子解决是讨论
- 【小程序自动化Minium】一、框架介绍和环境搭建
- Work notes: one time bag grabbing
- Canvas from getting started to persuading friends to give up (graphic version)
- Program design of dot matrix Chinese character display of basic 51 single chip microcomputer
- 【我可以做你的第一个项目吗?】GZIP的细节简介和模拟实现
- Reflection invokes transaction methods, resulting in transaction invalidation
- C language implements memcpy and memmove
- Chapitre 2 requête de base et tri
- 【测试平台开发】十七、接口编辑页面实现下拉级联选择,绑定接口所属模块...
猜你喜欢

The win11 installation system prompts that VirtualBox is incompatible and needs to uninstall the solution of virtual, but the uninstall list cannot find the solution of virtual
![[record of question brushing] 19. Delete the penultimate node of the linked list](/img/be/7e81e9376cb04566d669db4c606309.png)
[record of question brushing] 19. Delete the penultimate node of the linked list

Which is a good fixed asset management system? What are the fixed asset management platforms?
建议思源笔记能够兼容第三方同步盘

Program design of dot matrix Chinese character display of basic 51 single chip microcomputer
![[test platform development] 23. interface assertion function - save interface assertion and edit echo](/img/36/aed4feb6a4e40b6b5c06206a8ed440.png)
[test platform development] 23. interface assertion function - save interface assertion and edit echo

【测试平台开发】21. 完成发送接口请求显示响应头信息

关于flex布局justify-content:space-around最后一个不对齐的解决方法和为什么这样子解决是讨论

C thread lock and single multithreading are simple to use

【C語言】猜數字小遊戲+關機小程序
随机推荐
Chapter 2 basic query and sorting
【测试平台开发】二十、完成编辑页发送接口请求功能
[software test] redis abnormal test encountered in disk-to-disk work
Program design of dot matrix Chinese character display of basic 51 single chip microcomputer
win11安装系统提示virtualBox不兼容需要卸载virtual的解决办法,但是卸载列表找不到virtual的解决办法
Towhee 每周模型
C language introduction practice (11): enter a group of positive integers and sum the numbers in reverse order
Several hole filling methods of point cloud (mesh) (1)
[test platform development] 23. interface assertion function - save interface assertion and edit echo
【PyQt5安装以及使用】
[record of question brushing] 19. Delete the penultimate node of the linked list
Towhee weekly model
Qt| imitation text floating letter
Jetpack系列之Room中存Map结构
Authing 支持 Zadig 啦!云原生用户统一认证快速对接
C language implementation of classroom random roll call system
C language project practice: 24 point game calculator (based on knowledge points such as structure, pointer, function, array, loop, etc.)
Towhee weekly model
Question 142 of Li Kou: circular linked list 2
JS software unloading prompt expression changes with the mouse JS special effect

