Skip to content

Directory structure

Lellansin Huang edited this page Sep 7, 2020 · 2 revisions

Dependency Injection And directory structure. , so you can Place your code at will , but we still Several common directory structures are recommended. .

The simplest directory structure

In this structure, all files can be placed in the src Directory. In quick start projects or small-volume code, we often use this structure, our scaffolding also uses this method.

The following is the simplest structure of a function. The core includes f.yml Standardize the function information configuration file and the project structure of TypeScript.

.
โ”œโ”€โ”€ f.yml           # standard specification file
โ”œโ”€โ”€ package.json    # project dependencies
โ”œโ”€โ”€ src
โ”‚   โ””โ”€โ”€ index.ts    # function entry
โ””โ”€โ”€ tsconfig.json

Directory structure of medium-sized projects

As the amount of code increases, subdirectories are required to standardize our code. For functions, function portals and dependent services are common, so the following directory structure is available.

.
โ”œโ”€โ”€ f.yml             # standard specification file
โ”œโ”€โ”€ package.json      # project dependencies
โ”œโ”€โ”€ src
โ”‚   โ”œโ”€โ”€ function          # function entry
โ”‚   โ”‚   โ””โ”€โ”€ index.ts
โ”‚   โ””โ”€โ”€ service           # DI services directory
โ”‚       โ””โ”€โ”€ userService.ts
โ””โ”€โ”€ tsconfig.json

This directory can maintain relatively good isolation and scalability as the amount of code increases.