# oak-qapi **Repository Path**: yanjd/oak-qapi ## Basic Information - **Project Name**: oak-qapi - **Description**: 根据mysql的数据库表结构自动生成相应的增删改查接口(graphql) - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: https://qapi.yanjd.top/ - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-03-12 - **Last Updated**: 2021-04-08 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # oak-qapi #### 介绍 根据sqlite3数据库文件快速生成增删改查graphql接口。 #### 软件架构 基于deno.js开发。 #### 代码示例 *import_map.json* ```json { "imports": { "qapi/": "https://gitee.com/yanjd/oak-qapi/raw/1.0.0/", "oak_graphql/": "https://deno.land/x/oak_graphql@0.6.2/", "oak/": "https://deno.land/x/oak@v6.5.0/" } } ``` *mod.ts* ```js // deno run -A --import-map=import_map.json ./mod.ts import { Application, Router } from "oak/mod.ts"; import { graphqlPlayground, logger, oakAllowOrigin, oakJuwParse, } from "qapi/oak_plugins/mod.ts"; import { oakSqliteGraphql } from "qapi/mod.ts"; import { oakSqliteGraphqlAuth } from "qapi/plugin/auth/mod.ts"; import { oakSqliteGraphqlPermission, oakSqliteGraphqlPermissionInit, } from "qapi/middleware/permission/mod.ts"; import DexSqlite from "qapi/dex_sqlite/mod.ts"; const app = new Application(); const router = new Router(); router.get("/", (context) => { context.response.body = "home"; }); app.use(logger); app.use(oakAllowOrigin); // 允许跨域设置 app.use(oakJuwParse); // 解析cookie和header中的jwt app.use(graphqlPlayground()); app.use(router.routes()); app.use(router.allowedMethods()); app.use( await oakSqliteGraphql({ dex: DexSqlite({ dbPath: Deno.env.get("PORT") || "C:\\yanjd\\db\\qapi-blog.db", // 换成自己本地的数据库文件地址 }), async before(options: any) { await oakSqliteGraphqlPermissionInit(options); }, plugins: [oakSqliteGraphqlAuth], middlewares: [ oakSqliteGraphqlPermission({ whiteList: ["mutation_login"] }), ], }), ); const port = 8690; console.log(`http://localhost:${port}/graphql`); await app.listen({ port }); ```