Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: create kennisbank-api server #912

Merged
merged 21 commits into from
Oct 25, 2024
Merged

feat: create kennisbank-api server #912

merged 21 commits into from
Oct 25, 2024

Conversation

AliKdhim87
Copy link
Contributor

No description provided.

Copy link

vercel bot commented Oct 1, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
cms-frameless-io ❌ Failed (Inspect) Oct 25, 2024 10:55am
tiptap ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 25, 2024 10:55am

Copy link

codecov bot commented Oct 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

After generating the token, include it in your request headers as a Bearer token. Here's an example:

```ts
Authorization: Bearer API_TOKEN
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Authorization: Bearer API_TOKEN
Authorization: Token API_TOKEN


```shell
OVERIGE_OBJECT_API_PORT=4001
OVERIGE_OBJECT_API_CORS=http://localhost:3000 # If using multiple domains, separate them with a comma (e.g., 'http://localhost:3000, http://localhost:3001').
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

De # comment aan het eind van de regel, die kan gewoon voor het code block in de lopende tekst.

To start the service, open a terminal in the project root and run:

```shell
cd bin && bash ./deploy.sh pdc-dashboard prod up --build
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Op deze manier hoef je niet achteraf cd .. te doen, en kun je het command meerdere keren achter elkaar draaien zonder extra commands.

Suggested change
cd bin && bash ./deploy.sh pdc-dashboard prod up --build
( cd bin && bash ./deploy.sh pdc-dashboard prod up --build )

"url": "[email protected]:frameless/strapi.git",
"directory": "apps/overige-object-api"
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In de toekomst is het misschien leuk om twee versies te hebben van de Overige Objecten API:

  1. Strapi als bron. Optioneel, bijvoorbeeld met npm run start --strapi https://strapi.localhost:1337/"
  2. Filesystem als bron. Bijvoorbeeld npm run start --object-dir objects/ --object-types-dir object-types/

Utility functions om dit te maken zouden ook handig zijn voor tests. Bijvoorbeeld:

let server;
beforeEach(() => {
  server = serverFromFileSystem({
    objectDir: 'fixtures/scenario-5/objects',
    objectDir: 'fixtures/scenario-5/objects-types',
  });
});

doelgroep: 'eu-burger',
},
],
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ik zou het netter vinden om de const data buiten de functie te plaatsen.

*/
const handleGraphqlError = (error: any) => {
const errorMessage = error?.message || 'GraphQL error';
const errorCode = error?.extensions?.code || 400; // Handle extensions (specific to GraphQL)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is 500 niet logischer als default?

HTTP 500 De server snapt het zelf ook niet helemaal meer 😉

const handleHttpError = (response: Response) => {
const status = response.status;

let errorMessage = response.statusText || 'Unknown error';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unknown error is geen status. Doe dan status 500.

// Handle GraphQL-specific errors
if (data.errors && data.errors.length > 0) {
data.errors.forEach(handleGraphqlError); // Process each error
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

De volgende comments zijn echt heel erg stating the obvious, wat mij betreft kunnen ze weg.

  • // Default to an empty object if no headers are provided
  • // Check for non-successful responses (status not in the 2xx range)
  • // Process each error

* This is only available in development mode
*/
if (process.env.NODE_ENV === 'development') {
app.use('/api/v1/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kan dit niet beter gewoon onder /swagger/?

});

const swaggerDocument: any = yaml.load(fs.readFileSync(path.join(__dirname, './docs/openapi.yaml'), 'utf8'));
const whitelist = process.env.OVERIGE_OBJECT_API_CORS?.split(', ') || [];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Op deze manier weet typescript beter dat het een string[] is.

Suggested change
const whitelist = process.env.OVERIGE_OBJECT_API_CORS?.split(', ') || [];
const whitelist = (process.env.OVERIGE_OBJECT_API_CORS || '').split(', ');

@Robbert Robbert merged commit aea8d46 into main Oct 25, 2024
7 of 8 checks passed
@Robbert Robbert deleted the kennisbank-api branch October 25, 2024 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment