我有一个简单的问题:
如何创建端点并将其附加到我的项目?
我试图跟踪医生是徒劳的:
创建一个直接项目
npm init directus-project example-projectcd example-project; npx directus starthttp://0.0.0.0:8055/admin/content的直接管理
创建端点
cd ..,离开我的直接项目,npm init directus-extension/到/hello in src/indexcd demo-directus-endpoint; npm run build在directus项目中部署扩展
https://docs.directus.io/extensions/creating-extensions/
To deploy your extension, you have to move the output from the dist/ folder into your project's ./extensions/<extension-folder>/<extension-name>/ folder. <extension-folder> has to be replaced by the extension type in plural form (e.g. interfaces). <extension-name> should be replaced with the name of your extension.cd ../example-projectmkdir ./extensions/endpoints/democp -R ../demo-directus-endpoint/dist/index.js ./extensions/endpoints/demoindex.js看起来是这样的:
"use strict";module.exports=e=>{e.get("/hello",((e,l)=>l.send("Hello, World!")))};
npx directus start17:43:40 ✨ Loaded extensions: demo
17:43:40 ⚠️ PUBLIC_URL should be a full URL
17:43:40 ⚠️ Spatialite isn't installed. Geometry type support will be limited.
17:43:40 ✨ Server started at http://0.0.0.0:8055试图获取url http://0.0.0.0:8055/hello的
curl http://0.0.0.0:8055/hello => {"errors":[{"message":"Route /hello doesn't exist.","extensions":{"code":"ROUTE_NOT_FOUND"}}]}
17:43:55 ✨ request completed GET 404 /hello 8ms什么时候才能得到Hello, World! curl http://0.0.0.0:8055/hello呢?
谢谢你的帮助
发布于 2022-05-25 15:54:21
答案找到卷曲http://0.0.0.0:8055/demo/hello =>你好,世界!
https://stackoverflow.com/questions/72380698
复制相似问题