默认使用api路径
This commit is contained in:
parent
013180f7c2
commit
75144f0871
13
README.md
13
README.md
@ -15,6 +15,19 @@ Nodejs 构建的 RESTful 风格 WEB API
|
||||
2. HTTP Method 资源操作方式
|
||||
|
||||
|
||||
## TEST
|
||||
* 使用 RESTful 与 Graphql 结合的风格 API
|
||||
* 使用 JS 库直接实现对象解析为 Graphql
|
||||
|
||||
```JavaScript
|
||||
import KanaClient from 'kana-client'
|
||||
|
||||
// 期望调用的对象结构(ws)
|
||||
const client = await KanaClient('/graphql-ws')
|
||||
const { id, name, avatar } = await client.get({user:{ id, name, avatar }})
|
||||
const { }
|
||||
```
|
||||
|
||||
|
||||
## Install
|
||||
```bash
|
||||
|
16
index.js
16
index.js
@ -409,12 +409,12 @@ const app = expressWs(express()).app
|
||||
app.use(express.json())
|
||||
app.use(express.urlencoded({ extended: false }))
|
||||
app.use(session({ secret: 'kana', name: 'sid', resave: false, saveUninitialized: false, cookie: { maxAge: 180 * 24 * 3600000 }, store: session_store }))
|
||||
app.use('/data/file/', express.static('data/file'))
|
||||
app.ws('/', websocketer)
|
||||
app.route('/').get(index_get)
|
||||
app.route('/account').get(profile).post(online, uploadfile)
|
||||
app.route('/session').get(online, session_list).post(session_create).delete(online, sessionDeleteSelf)
|
||||
app.route('/session/:sid').delete(online, session_delete)
|
||||
app.route('/:name').get(object_list).post(object_create).put(db_compact)
|
||||
app.route('/:name/:_id').get(object_load).post(online, file_upload).put().patch(online, object_patch).delete(online, object_remove)
|
||||
app.use('/api/data/file/', express.static('data/file'))
|
||||
app.ws('/api', websocketer)
|
||||
app.route('/api/').get(index_get)
|
||||
app.route('/api/account').get(profile).post(online, uploadfile)
|
||||
app.route('/api/session').get(online, session_list).post(session_create).delete(online, sessionDeleteSelf)
|
||||
app.route('/api/session/:sid').delete(online, session_delete)
|
||||
app.route('/api/:name').get(object_list).post(object_create).put(db_compact)
|
||||
app.route('/api/:name/:_id').get(object_load).post(online, file_upload).put().patch(online, object_patch).delete(online, object_remove)
|
||||
app.listen(2333)
|
||||
|
Loading…
Reference in New Issue
Block a user