What is the recommended project structure when developing an Angular 6 application and an API server that need to share type definitions?
For example:
On the client side:
this.httpService.get<Hero[]>(apiUrl + '/heroes')
On the server side:
app.get('/heroes', async (req, res) => {
const heroes: Hero[] = await db.Heroes.findAll<Hero>()
res.status(200).send(heroes)
}
The goal is to share the definition of Hero
between both projects.
- Should I create my server within a sub-directory of the Angular app?
- Is it better to build the server app first and then somehow reference its source code from the Angular app?
- Or should I create a separate Models project, define all the types there, and find a way to reference them?