{"id":15567050,"url":"https://github.com/vectier/springpress","last_synced_at":"2025-04-23T23:49:00.680Z","repository":{"id":39970348,"uuid":"485328802","full_name":"vectier/springpress","owner":"vectier","description":"Writing Express but feel like Spring Boot","archived":false,"fork":false,"pushed_at":"2023-01-24T12:46:56.000Z","size":297,"stargazers_count":9,"open_issues_count":2,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-23T23:48:53.827Z","etag":null,"topics":["express","mvc","nodejs","server","springboot","typescript"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/vectier.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-04-25T10:42:43.000Z","updated_at":"2024-03-04T18:54:25.000Z","dependencies_parsed_at":"2023-02-13T21:30:52.543Z","dependency_job_id":null,"html_url":"https://github.com/vectier/springpress","commit_stats":null,"previous_names":["riflowth/springpress"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vectier%2Fspringpress","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vectier%2Fspringpress/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vectier%2Fspringpress/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vectier%2Fspringpress/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vectier","download_url":"https://codeload.github.com/vectier/springpress/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250535110,"owners_count":21446506,"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":["express","mvc","nodejs","server","springboot","typescript"],"created_at":"2024-10-02T17:09:49.161Z","updated_at":"2025-04-23T23:49:00.628Z","avatar_url":"https://github.com/vectier.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Springpress\n\nA Top-level framework of Express.js for developing clean architecture API service, especially on [TypeScript](https://github.com/microsoft/TypeScript).\n\n**Springpress** provides basic *Express.js* functions and MVC utilities related out of the box. Let you deep-dive into the world of [OOP](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/Object-oriented_programming) and the scent of our motivation, *Spring Boot* with **Springpress**.\n\n## Installation\n\n\u003e **Node.js 16.15.0 (LTS) is required**\n\nUsing npm:\n```\n$ npm install springpress\n```\n\nUsing yarn:\n```\n$ yarn add springpress\n```\n\n## Usage\n\n*Assume you are creating a dog controller that sends a response of the dog's name when requesting to `/dog/name`.*\n\n### Server\n\nFirst, you need to create a main class that extends `Springpress` class. This class will store all of your things. *e.g. services, controllers, repositories initialization*.\n\n```ts\nimport { Springpress } from 'springpress';\n\nclass ExampleServer extends Springpress {\n\n  public onStartup(): Promise\u003cvoid\u003e {\n    // This code will run when your start your application.\n    // All of initialization should do it here.\n  }\n\n}\n```\n\nDon't forget to call `Springpress#listen` to bind to and to listen for conections. This method returns an [http.Server](https://nodejs.org/docs/latest-v16.x/api/http.html#class-httpserver) object (the built-in HTTP module). *You can use this instance in your testing framework to work with HTTP*.\n\n```ts\nconst port = 3000; // you can specify whatever port you want :)\nconst exampleServer = new ExampleServer(port);\nexampleServer.listen();\n```\n\n### Controller\n\n#### Controller Mapping\n\nEasily define your controller with `@ControllerMapping` decorator:\n\n```ts\n@ControllerMapping('/dog') // \u003c-- Decorator here!\nclass DogController extends Controller {\n  // Routes implementation will be here.\n}\n```\n\nThe `@ControllerMapping` decorator will mount your class on a router with the path where you specified in the first decorator parameter. In this case, this class will be mapped with `/dog` on the router.\n\n- A client can connect by `http://localhost:3000/dog/` followed by your implemented route. *(port 3000 is just an example)*\n- On this step, you will not actually be able to access it. You need to implement a route first by following the next step.\n\n#### Route Mapping\n\nEasily define your route with `@RouteMapping` decorator:\n\n```ts\n@ControllerMapping('/dog')\nclass DogController extends Controller {\n\n  @RouteMapping('/name', Methods.GET) // \u003c-- Decorator here!\n  private async getName(req: Request, res: Response) {\n    res.status(200).json({\n      name: 'Doge',\n    });\n  }\n\n}\n```\n\nThe `@RouteMapping` decorator will mount your decorated method as a routing destination of an HTTP request in a controller.\n\nA RouteMapping parameter\n- path - a string of route path\n  - It can be anything that [Express.js](https://expressjs.com/en/guide/routing.html) routing support\n- method - an enum of HTTP method (You can use `Methods` imported from Springpress)\n\nNow, your client will see `http://localhost:3000/dog/name` and get a response like below in a JSON format.\n\n```json\n{\n  \"name\": \"Doge\"\n}\n```\n\n#### Controller Registration\n\nEverything above in the Controller section will not work if you haven't registered the controller in the Server class.\n\n```ts\nimport { Springpress } from 'springpress';\nimport { DogController } from './controllers/DogController';\n\nclass ExampleServer extends Springpress {\n\n  public onStartup(): Promise\u003cvoid\u003e {\n    // Don't forget here!\n    const controllerRegistry = this.getControllerRegistry();\n    controllerRegistry.register(new DogController());\n  }\n\n}\n```\n\n## Contribution\n\nThere are many ways in which you can participate in this project, for example:\n\n- [Submit bugs and feature requests](https://github.com/riflowth/springpress/issues).\n- Review [source code changes](https://github.com/riflowth/tier-discord-bot/pulls).\n- Fixing issues and contributing directly to the code base by [submitting pull requests](https://github.com/riflowth/tier-discord-bot/pulls).\n\n## License\n\nCopyright (c) Vectier. All rights reserved.\n\nLicensed under the [MIT](https://github.com/riflowth/nextpress/blob/main/LICENSE) license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvectier%2Fspringpress","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvectier%2Fspringpress","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvectier%2Fspringpress/lists"}