Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/peu77/expresswrapper
Simple construct for an express application.
https://github.com/peu77/expresswrapper
backend express npm-package simple typescript
Last synced: 10 days ago
JSON representation
Simple construct for an express application.
- Host: GitHub
- URL: https://github.com/peu77/expresswrapper
- Owner: Peu77
- Created: 2022-07-22T19:58:28.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-07-31T08:02:58.000Z (over 2 years ago)
- Last Synced: 2024-12-15T05:38:36.762Z (24 days ago)
- Topics: backend, express, npm-package, simple, typescript
- Language: TypeScript
- Homepage:
- Size: 38.1 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ExpressWrapper
[![install size](https://packagephobia.com/badge?p=@peu77/expresswrapper)](https://packagephobia.com/result?p=@peu77/expresswrapper)
Simple construct for an express application.
## Installation
### With NPM
``npm i @peu77/expresswrapper``
## With Yarn
``yarn add @peu77/expresswrapper``
### You need to create a service and a controller
###
#### Imports
```typescript
import {
Controller,
initControllers,
RouteType,
Service,
generateListener,
DependencyImpl
} from '@peu77/expresswrapper';
```#### Basic service
```typescript
const service: Service = {
listeners: [
generateListener(RouteType.POST, "test", (data: any) => {
return {
success: true,
message: "finished",
status: 200,
data: {}
}
})
]
}
```#### Basic controller which use the service
```typescript
const controller: Controller = {
prefix: "/api",
service: service,
routes: [
{
path: "test",
type: RouteType.POST,
guards: [],
dependencies: []
}
]
}
```#### If you have a controller you can use the initControllers function
```typescript
const app = express();
app.listen(3000, () => {
initControllers(app, [controller]);
})
```