{"id":14983135,"url":"https://github.com/minhdtb/minmin","last_synced_at":"2025-10-29T21:30:39.693Z","repository":{"id":25542392,"uuid":"104459388","full_name":"minhdtb/minmin","owner":"minhdtb","description":"MinMin  - a tiny typescript web framework based on Express","archived":false,"fork":false,"pushed_at":"2022-12-07T07:42:37.000Z","size":1274,"stargazers_count":16,"open_issues_count":12,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-02T04:51:13.163Z","etag":null,"topics":["framework","minimalist","minmin","spring","spring-mvc","typescript","web"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/minhdtb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-22T09:52:29.000Z","updated_at":"2024-01-29T11:37:58.000Z","dependencies_parsed_at":"2023-01-14T02:55:31.622Z","dependency_job_id":null,"html_url":"https://github.com/minhdtb/minmin","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minhdtb%2Fminmin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minhdtb%2Fminmin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minhdtb%2Fminmin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minhdtb%2Fminmin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/minhdtb","download_url":"https://codeload.github.com/minhdtb/minmin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238892222,"owners_count":19548152,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["framework","minimalist","minmin","spring","spring-mvc","typescript","web"],"created_at":"2024-09-24T14:06:47.244Z","updated_at":"2025-10-29T21:30:34.396Z","avatar_url":"https://github.com/minhdtb.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\u003cimg align=\"center\" src=\"https://github.com/minhdtb/minmin/blob/master/images/minmin-logo.png\"/\u003e\u003c/p\u003e\r\n\r\n[![Apache V2 License](http://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/minhdtb/minmin/blob/master/LICENSE)\r\n\r\n## 1. Introduction\r\n\r\nMinMin is a tiny web framework entirely written in typescript, based on [ExpressJS](https://expressjs.com/) and inspired by Java Web\r\n\r\n## 2. How to use\r\n\r\n### Getting started\r\n\r\n#### Install minmin\r\n\r\n```npm install --save minmin```\r\n\r\nChange tsconfig.json looks like\r\n\r\n```json\r\n{\r\n  \"compilerOptions\": {     \r\n      \"lib\": [\r\n      \"dom\",\r\n      \"es2015\"\r\n      ],\r\n      \"target\": \"es5\",\r\n      \"moduleResolution\": \"node\",\r\n      \"experimentalDecorators\": true,\r\n      \"emitDecoratorMetadata\": true,      \r\n  }\r\n}\r\n```\r\n\r\n#### Define controller \r\n\r\nFirstly we create ```ApiController.ts``` file then define controller with ```base url``` is ```/api```\r\n\r\n```ts\r\n@Controller('api')\r\nclass ApiController {\r\n}\r\n```\r\n\r\n#### Define request handler\r\n\r\nThe next step, we need define request handler like this\r\n\r\n```ts\r\n@Controller('api')\r\nclass ApiController {\r\n\r\n  @Post('login')\r\n  private async login(@Data('username') username: string,\r\n                      @Data('password') password: string) {\r\n    let user = await User.findOne({username: username});\r\n    if (user) {\r\n      let compare = await user.comparePassword(password);\r\n      if (compare) {              \r\n        return new Result('user', user);\r\n      } else {\r\n        return new Error(401, \"Invalid username or password.\");\r\n      }\r\n    } else {\r\n        return new Error(404, \"Username not found.\");\r\n    }\r\n  }\r\n}\r\n```\r\nThe upper code is equivalent to http method handler in expressjs like bellow\r\n```js\r\napp.post('/api/login', function(req, res) {\r\n   var username = req.body.username\r\n   var password = req.body.password  \r\n   ...\r\n})\r\n```\r\n\r\n#### Start server\r\n\r\nThe last step is starting web server\r\n\r\n```ts\r\nimport {WebServer} from \"minmin\"\r\nimport './controllers/ApiController' // import the controller here (very important)\r\n\r\nconst server = new WebServer();\r\nserver.setPort(3000);\r\nserver.start();\r\n```\r\n\r\n### Support Dependency Injection\r\n\r\nSupport dependency injection since version 0.0.32\r\n\r\n```ts\r\nimport {Controller, Service, Inject} from \"minmin\"\r\n\r\n@Service()\r\nclass MyService {\r\n\r\n  action(): void {\r\n  }\r\n  \r\n}\r\n\r\n@Controller('api')\r\nclass ApiController {\r\n\r\n  @Inject()\r\n  myService: MyService;\r\n  \r\n  \r\n}\r\n\r\n```\r\n\r\n## 3. Decorators list\r\n\r\n### Methods\r\n\r\n```@Get```\r\n```@Post```\r\n```@Put```\r\n```@Delete```\r\n\r\n### Parameters\r\n\r\n```@Param```\r\n```@Query```\r\n```@Data```\r\n```@Session``` (deprecated)\r\n```@Request```\r\n\r\n### Dependency Injection\r\n\r\n```@Inject```\r\n```@Service```\r\n\r\n## 4. Classes list\r\n\r\n```WebServer```\r\n```Result```\r\n```Error```\r\n```View```\r\n```Redirect```\r\n\r\n## 5. Template and demo\r\n\r\n#### simple: https://github.com/minhdtb/minmin-template\r\n#### with NuxtJS: https://github.com/minhdtb/minmin-nuxt-template\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fminhdtb%2Fminmin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fminhdtb%2Fminmin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fminhdtb%2Fminmin/lists"}