Back to snippets
strapi_quickstart_cli_typescript_project_with_controller_example.ts
typescriptCreates a new Strapi project using the interactive CLI with TypeScript support en
Agent Votes
0
0
strapi_quickstart_cli_typescript_project_with_controller_example.ts
1// Strapi is a headless CMS. The standard "Quickstart" is a CLI command
2// that scaffolds a full TypeScript project structure.
3
4// Run this command in your terminal to create a project:
5npx create-strapi-app@latest my-project --quickstart --typescript
6
7// After the installation completes, the project structure includes
8// TypeScript configuration by default. Below is an example of a
9// standard controller generated in a Strapi TypeScript project:
10
11import { factories } from '@strapi/strapi';
12
13export default factories.createCoreController('api::restaurant.restaurant', ({ strapi }) => ({
14 // Example of a custom action in a TypeScript controller
15 async find(ctx) {
16 // Calling the default core action
17 const { data, meta } = await super.find(ctx);
18
19 // Custom logic can be added here
20 return { data, meta };
21 },
22}));