如果说博客还有些想向他人展示的欲望的话,那么这个API则纯粹是为了自己纵览自己的输入而做的东西。
做UI的目的是看起来更方便,编辑啊什么的。
example:
https://github.com/avanelli/fastify-realworld-example-app/blob/main/lib/routes/users/index.js https://github.com/fastify/fluent-json-schema
- 把 data/movies.js 中的 series 条目放到 data/series.js 中(这是个大工程啊)
- 把 https://neodb.social/users/tianheg/ 中标记的内容放到 api 中(只剩唱片没转移了)
- routes files merged into main server.js
- add page, limit, search ability
- added security measures
- refactor code structure(src)
- add test
- try pressure test with Artillery
- json data to PostgreSQL DB
PostgreSQL Database(by Railway)
Abandon Supabase because of the auto-paused free project policy
The data will only be updated after redeployment? Maybe this is the problem of Vercel.
Refer:
Refer:
Use GitHub action
The bug likely occurs due to the asynchronous nature of the
import()
function used in theapp.register()
calls. When you useimport()
insideapp.register()
, it returns a promise that resolves to the module, and Fastify'sregister
method might not be set up to handle promises directly in this manner. This can lead to a race condition where Fastify starts setting up routes before the Swagger plugins are fully registered and configured, resulting in the Swagger UI not being aware of any routes.
https://fastify.dev/docs/latest/Reference/Routes/#async-await
server.js:
async function createRoute(path, data, opts) {
app.get(path, { schema: opts.schema }, async (request, reply) => {
const { page, limit, search } = request.query;
const paginatedData = await getPaginatedData(data, search, page, limit);
- reply.send(paginatedData);
+ return reply.send(paginatedData);
});
}
With current code, home page title is http://127.0.0.1:3000
, not https://api.tianheg.org/
(SOLVED)
Explicitly set baseUrl to https://api.tianheg.org