Developing the Business Logic
Learn the steps to develop a business logic for a Deno application.
We'll cover the following...
Steps to develop a business logic
Previously, we stated that our business logic is the most important part of our application. Even though ours will be super simple for now, that’s what we’ll develop first.
Since we’ll be using TypeScript for our application, let’s define our Museum
object. Follow these steps:
- Go into
src/museums/types.ts
, and create a type that defines aMuseum
:
Press + to interact
export type Museum = {id: string,name: string,description: string,location: {lat: string,lng: string}}
Make sure it’s exported because we’ll be using this across other files.
Now that we know the type, we must create some business logic to get a list of museums.
- Inside
src/museums/types.ts
, create an interface that will defineMuseumController
. It should contain a method that lists all the museums:
Press + to interact
export interface MuseumController {getAll: () => Promise<Museum[]>;}
- Inside
src/museums/controller.ts
, create a class that will act as the controller. It should contain a function namedgetAll
. In the future, this is where the business logic will live, but for now, we can return an empty array: