Add redirects
All checks were successful
Gitea Actions Demo / build (push) Successful in 5m20s

This commit is contained in:
2023-12-04 16:46:16 -07:00
parent 6ecdd5a0b8
commit d00fe6fdb7
11 changed files with 82 additions and 50 deletions

14
.env.example Normal file
View File

@@ -0,0 +1,14 @@
JWT_SECRET=#jBhALXeYXC3$#e9
RAPID_API_KEY=
IRC_SERVER=irc.libera.chat
IRC_CHANNEL="##usdev-dev"
REDIS_HOST=localhost
REDIS_PASS=password
S3_ENDPOINT="localhost"
S3_PORT=9000
S3_USE_SSL=false
S3_ACCESS_KEY="localminio"
S3_SECRET_KEY="localminio"
S3_BUCKET="devbucket"

3
.gitignore vendored
View File

@@ -33,4 +33,7 @@ lerna-debug.log*
!.vscode/tasks.json
!.vscode/launch.json
.env
.env.bak
!.vscode/extensions.json
data/

View File

@@ -1,54 +1,28 @@
# api.us.dev
# us.dev Generalized API
## Description
AKA _the monolith_
[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
## Quickstart
## Installation
Dependencies:
```bash
$ yarn install
- Docker
- Node 18
```sh
# Copy example .env
cp .env.example .env
# Install Dependencies
yarn
# Start local services
docker compose up -d
# Copy default data into local minio
cp -r default/* data/minio/devbucket
# Start Application
yarn start:dev
```
## Running the app
```bash
# development
$ yarn run start
# watch mode
$ yarn run start:dev
# production mode
$ yarn run start:prod
```
## Test
```bash
# unit tests
$ yarn run test
# e2e tests
$ yarn run test:e2e
# test coverage
$ yarn run test:cov
```
## Support
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
## Stay in touch
- Author - [Kamil Myśliwiec](https://kamilmysliwiec.com)
- Website - [https://nestjs.com](https://nestjs.com/)
- Twitter - [@nestframework](https://twitter.com/nestframework)
## License
Nest is [MIT licensed](LICENSE).
Visit http://localhost:3000/api
## Configuration

View File

@@ -1,5 +1,20 @@
version: '3'
services:
minio:
image: bitnami/minio
networks:
- db_net
ports:
- 9000:9000
- 9001:9001
volumes:
- ./data/minio:/bitnami/minio/data
environment:
- MINIO_ROOT_USER=localminio
- MINIO_ROOT_PASSWORD=localminio
- MINIO_DEFAULT_BUCKETS=devbucket
env_file:
- .env
redis:
image: redis
networks:

View File

@@ -19,6 +19,7 @@ import { BullModule } from '@nestjs/bull';
import { ScheduleModule } from '@nestjs/schedule';
import { RedisClientOptions } from 'redis';
import { redisStore } from 'cache-manager-redis-yet';
import { RedirectsModule } from './redirects/redirects.module';
@Module({
imports: [
@@ -72,8 +73,9 @@ import { redisStore } from 'cache-manager-redis-yet';
OgScraperModule,
MinioModule,
KvModule,
RedirectsModule,
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
export class AppModule { }

View File

@@ -10,6 +10,10 @@ export default () => ({
port: parseInt(process.env.IRC_PORT ?? '6697'),
channel: process.env.IRC_CHANNEL ?? '#usdev',
password: process.env.IRC_PASSWORD ?? '',
nick:
process.env.IRC_NICK ?? process.env.NODE_ENV === 'production'
? 'us-bot'
: 'us-dev',
},
redis: {
host: process.env.REDIS_HOST ?? 'redis-master',

View File

@@ -18,7 +18,7 @@ export class IrcbotService {
public readonly domainrProxy: DomainrproxyService,
) {
if (!this.configService.get<boolean>('irc.enabled')) return;
const nick = process.env.NODE_ENV === 'production' ? 'us-bot' : 'us-dev';
const nick = this.configService.get<string>('irc.nick') || 'us-dev';
const ircPassword = this.configService.get<string>('irc.password');
this.socket = connect({
port: this.configService.get<number>('irc.port'),
@@ -30,7 +30,7 @@ export class IrcbotService {
if (ircPassword) this.client.pass(ircPassword);
this.client.user(nick, `us.dev bot ${process.env.NODE_ENV}`);
this.client.nick(nick);
// this.client.send('nickserv', `identify ${nick} ${ircPassword}`);
this.client.send('nickserv', `identify ${nick} ${ircPassword}`);
console.log(nick);
const channel: string = this.configService.get<string>(
'irc.channel',

View File

@@ -15,8 +15,8 @@ export class MinioService {
) {
this.client = new Client({
endPoint: this.configService.get<string>('S3_ENDPOINT', 's3.hooli.co'),
port: this.configService.get<number>('S3_PORT', 443),
useSSL: true,
port: Number(this.configService.get<number>('S3_PORT', 443)),
useSSL: this.configService.get<string>('S3_USE_SSL', 'true') === 'true',
accessKey: this.configService.get<string>('S3_ACCESS_KEY', ''),
secretKey: this.configService.get<string>('S3_SECRET_KEY', ''),
});

View File

@@ -0,0 +1,4 @@
import { Controller } from '@nestjs/common';
@Controller('redirects')
export class RedirectsController {}

View File

@@ -0,0 +1,7 @@
import { Module } from '@nestjs/common';
import { RedirectsController } from './redirects.controller';
@Module({
controllers: [RedirectsController]
})
export class RedirectsModule {}

View File

@@ -0,0 +1,9 @@
import { Controller, Get } from '@nestjs/common';
@Controller({ host: "requiredreading.dev" })
export class RequiredReadingController {
@Get('')
getRoot() {
return "Hello required reading"
}
}