@hammerhq/plugin-http
v2.2.1
Published
😎 HTTP Plugin for Hammer
Downloads
5
Maintainers
Readme
📦 Installation
$ npm install @hammerhq/plugin-http
🚀 Usage
import { bootstrap } from "@hammerhq/core";
import { HTTPPlugin } from "@hammerhq/plugin-http";
import { Client } from "discord.js";
import { join } from "path";
// create your own controller or download them via npm!
import { MyController } from "./controllers/MyController";
const client = new Client(ClientOptions);
async function main() {
await bootstrap({
client,
i18n: {
defaultLocale: "en", // default locale, see @hammerhq/localization
directory: join(__dirname, "..", "locales"), // locales directory, see @hammerhq/localization
},
plugins: [
// hammer plugins here. You can download them with hammer cli, from npm and create your own!
HTTPPlugin.forRoot({
port: 3000, // http server port here
controllers: [MyController], // controllers here
}),
],
});
await client.login(CONFIG.BOT_TOKEN);
}
main();
🌳 Creating a controller
import {
APIRes,
Controller,
Get,
HTTPStatus,
Server,
} from "@hammerhq/plugin-http";
import { Server as HTTPServer } from "http";
@Controller("/example")
export class ExampleController {
@Server()
server!: HTTPServer;
@Get("/")
getHelloWorld(): APIRes<any> {
return {
statusCode: HTTPStatus.OK,
message: "Hello, world!",
data: this.server.address(),
};
}
}
🧦 Looking For Contributors
We are looking for contributors to actively work on Hammer and to contribute to the repos. There is still lots of work to do. If you are interested in contributing, please join our Discord server. (There will be a surprise for early contributors!)
🔑 License
Copyright © 2022 Barış DEMİRCİ.
Distributed under the GPL-3.0 License. See LICENSE
for more information.
🧦 Contributing
This repo is open for #hacktoberfest. Feel free to use GitHub's features.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/my-feature
) - Run prettier (
npm run format
) - Commit your Changes (
git commit -m 'my awesome feature my-feature'
) - Push to the Branch (
git push origin feature/my-feature
) - Open a Pull Request
⭐️ Show your support
Give a ⭐️ if this project helped you!
☎️ Contact
- Mail: [email protected]
- Discord: https://338.rocks/discord
- Website: https://hammer.338.rocks
- Documentation: https://hammer.338.rocks/docs/plugins/http