-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add nx server+client apps and shared lib
- Loading branch information
Showing
88 changed files
with
22,018 additions
and
9,475 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export OAUTH_CALLBACK_URL="http://localhost:3000/auth/callback" | ||
export POST_AUTH_REDIRECT="http://localhost:4200/auth" | ||
|
||
export DB_HOST="127.0.0.1" | ||
export DB_PORT=54321 | ||
export DB_USERNAME="spincycle" | ||
export DB_PASSWORD="spincycle" | ||
export DB_DATABASE="spincycle" | ||
export REDIS_URL="redis://localhost:63791" | ||
export DISCOGS_KEY="WnLGBmVhAiSqeOklehdG" | ||
export DISCOGS_SECRET="GsxNVzKifRhjpqnMIBRenYRfmTMMYDko" | ||
export DISCOGS_USER_AGENT="SpinCycle/0.1" | ||
|
||
export JWT_SECRET="a1f373cfe890e284a9027b56763b0d7898c1fdf84cbf41f1788d8824409472a6" | ||
export SESSION_SECRET="791e1bd6315a06038d0c3fa3b82c5f9555162619d82373293234d4484d42da78" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export OAUTH_CALLBACK_URL="where the discogs oauth flow should redirect to" | ||
export POST_AUTH_REDIRECT="the client URL that the API should redirect to after oauth" | ||
|
||
export DB_HOST="database host" | ||
export DB_PORT=5432 | ||
export DB_USERNAME="spincycle" | ||
export DB_PASSWORD="spincycle" | ||
export DB_DATABASE="spincycle" | ||
export REDIS_URL="redis URL" | ||
export DISCOGS_KEY="discogs consumer key" | ||
export DISCOGS_SECRET="discogs consumer secret" | ||
export DISCOGS_USER_AGENT="SpinCycle/0.1" | ||
|
||
export JWT_SECRET="secure secret" | ||
export SESSION_SECRET="another secure secret" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dotenv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,3 +40,8 @@ Thumbs.db | |
|
||
.nx/cache | ||
.nx/workspace-data | ||
|
||
.angular | ||
|
||
vite.config.*.timestamp* | ||
vitest.config.*.timestamp* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
/dist | ||
/coverage | ||
/.nx/cache | ||
/.nx/workspace-data | ||
/.nx/workspace-data | ||
.angular |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
{ | ||
"singleQuote": true | ||
"plugins": ["@trivago/prettier-plugin-sort-imports"], | ||
"singleQuote": true, | ||
"printWidth": 120, | ||
"semi": true, | ||
"importOrderParserPlugins": ["typescript", "decorators-legacy"], | ||
"importOrder": ["^@$", "<THIRD_PARTY_MODULES>", "^[./]"], | ||
"importOrderSeparation": true, | ||
"importOrderSortSpecifiers": true, | ||
"trailingComma": "all" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,82 +1,20 @@ | ||
# SpinCycleMono | ||
# Spin Cycle | ||
|
||
<a alt="Nx logo" href="https://nx.dev" target="_blank" rel="noreferrer"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-logo.png" width="45"></a> | ||
 | ||
|
||
✨ Your new, shiny [Nx workspace](https://nx.dev) is almost ready ✨. | ||
So, you spent all your money on records, and now you can't decide which one to listen to next... | ||
|
||
[Learn more about this workspace setup and its capabilities](https://nx.dev/nx-api/nest?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) or run `npx nx graph` to visually explore what was created. Now, let's get you up to speed! | ||
Spin Cycle sends you a randomly selected record (or CD! or cassette! or whatever!) from your collection on Discogs every morning. | ||
|
||
## Finish your CI setup | ||
- We make sure to cycle through your entire collection before we send a duplicate | ||
- You can select a specific sub-collection in Discogs for recommendations | ||
- Tell us you didn't listen to something and we'll put it back in the mix | ||
|
||
[Click here to finish setting up your workspace!](https://cloud.nx.app/connect/kQxZUV0S1Q) | ||
### TODO: | ||
|
||
|
||
## Run tasks | ||
|
||
To run the dev server for your app, use: | ||
|
||
```sh | ||
npx nx serve spin-cycle | ||
``` | ||
|
||
To create a production bundle: | ||
|
||
```sh | ||
npx nx build spin-cycle | ||
``` | ||
|
||
To see all available targets to run for a project, run: | ||
|
||
```sh | ||
npx nx show project spin-cycle | ||
``` | ||
|
||
These targets are either [inferred automatically](https://nx.dev/concepts/inferred-tasks?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) or defined in the `project.json` or `package.json` files. | ||
|
||
[More about running tasks in the docs »](https://nx.dev/features/run-tasks?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) | ||
|
||
## Add new projects | ||
|
||
While you could add new projects to your workspace manually, you might want to leverage [Nx plugins](https://nx.dev/concepts/nx-plugins?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) and their [code generation](https://nx.dev/features/generate-code?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) feature. | ||
|
||
Use the plugin's generator to create new projects. | ||
|
||
To generate a new application, use: | ||
|
||
```sh | ||
npx nx g @nx/nest:app demo | ||
``` | ||
|
||
To generate a new library, use: | ||
|
||
```sh | ||
npx nx g @nx/node:lib mylib | ||
``` | ||
|
||
You can use `npx nx list` to get a list of installed plugins. Then, run `npx nx list <plugin-name>` to learn about more specific capabilities of a particular plugin. Alternatively, [install Nx Console](https://nx.dev/getting-started/editor-setup?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) to browse plugins and generators in your IDE. | ||
|
||
[Learn more about Nx plugins »](https://nx.dev/concepts/nx-plugins?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) | [Browse the plugin registry »](https://nx.dev/plugin-registry?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) | ||
|
||
|
||
[Learn more about Nx on CI](https://nx.dev/ci/intro/ci-with-nx#ready-get-started-with-your-provider?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) | ||
|
||
## Install Nx Console | ||
|
||
Nx Console is an editor extension that enriches your developer experience. It lets you run tasks, generate code, and improves code autocompletion in your IDE. It is available for VSCode and IntelliJ. | ||
|
||
[Install Nx Console »](https://nx.dev/getting-started/editor-setup?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) | ||
|
||
## Useful links | ||
|
||
Learn more: | ||
|
||
- [Learn more about this workspace setup](https://nx.dev/nx-api/nest?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) | ||
- [Learn about Nx on CI](https://nx.dev/ci/intro/ci-with-nx?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) | ||
- [Releasing Packages with Nx release](https://nx.dev/features/manage-releases?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) | ||
- [What are Nx plugins?](https://nx.dev/concepts/nx-plugins?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) | ||
|
||
And join the Nx community: | ||
- [Discord](https://go.nx.dev/community) | ||
- [Follow us on X](https://twitter.com/nxdevtools) or [LinkedIn](https://www.linkedin.com/company/nrwl) | ||
- [Our Youtube channel](https://www.youtube.com/@nxdevtools) | ||
- [Our blog](https://nx.dev/blog?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) | ||
- [x] Authentication with Discogs | ||
- [ ] Messaging (SMTP) | ||
- [ ] Scheduling | ||
- [ ] History UI | ||
- [ ] Settings UI (custom time, collection) | ||
- [ ] Donation-based SMS option (?) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const nx = require('@nx/eslint-plugin'); | ||
const baseConfig = require('../../eslint.config.cjs'); | ||
|
||
module.exports = [ | ||
...baseConfig, | ||
...nx.configs['flat/angular'], | ||
...nx.configs['flat/angular-template'], | ||
{ | ||
files: ['**/*.ts'], | ||
rules: { | ||
'@angular-eslint/directive-selector': [ | ||
'error', | ||
{ | ||
type: 'attribute', | ||
prefix: 'sc', | ||
style: 'camelCase', | ||
}, | ||
], | ||
'@angular-eslint/component-selector': [ | ||
'error', | ||
{ | ||
type: 'element', | ||
prefix: 'sc', | ||
style: 'kebab-case', | ||
}, | ||
], | ||
}, | ||
}, | ||
{ | ||
files: ['**/*.html'], | ||
// Override or add rules here | ||
rules: {}, | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
{ | ||
"name": "spin-cycle-client", | ||
"$schema": "../../node_modules/nx/schemas/project-schema.json", | ||
"projectType": "application", | ||
"prefix": "app", | ||
"sourceRoot": "apps/spin-cycle-client/src", | ||
"tags": [], | ||
"targets": { | ||
"build": { | ||
"executor": "@angular-devkit/build-angular:application", | ||
"outputs": ["{options.outputPath}"], | ||
"options": { | ||
"outputPath": "dist/apps/spin-cycle-client", | ||
"index": "apps/spin-cycle-client/src/index.html", | ||
"browser": "apps/spin-cycle-client/src/main.ts", | ||
"polyfills": ["zone.js"], | ||
"tsConfig": "apps/spin-cycle-client/tsconfig.app.json", | ||
"inlineStyleLanguage": "scss", | ||
"assets": [ | ||
{ | ||
"glob": "**/*", | ||
"input": "apps/spin-cycle-client/public" | ||
} | ||
], | ||
"styles": ["apps/spin-cycle-client/src/styles.scss"], | ||
"scripts": [] | ||
}, | ||
"configurations": { | ||
"production": { | ||
"budgets": [ | ||
{ | ||
"type": "initial", | ||
"maximumWarning": "500kb", | ||
"maximumError": "1mb" | ||
}, | ||
{ | ||
"type": "anyComponentStyle", | ||
"maximumWarning": "4kb", | ||
"maximumError": "8kb" | ||
} | ||
], | ||
"fileReplacements": [ | ||
{ | ||
"replace": "environments/environment.ts", | ||
"with": "environments/environment.prod.ts" | ||
} | ||
], | ||
"outputHashing": "all" | ||
}, | ||
"development": { | ||
"optimization": false, | ||
"extractLicenses": false, | ||
"sourceMap": true | ||
} | ||
}, | ||
"defaultConfiguration": "production" | ||
}, | ||
"serve": { | ||
"executor": "@angular-devkit/build-angular:dev-server", | ||
"configurations": { | ||
"production": { | ||
"buildTarget": "spin-cycle-client:build:production" | ||
}, | ||
"development": { | ||
"buildTarget": "spin-cycle-client:build:development" | ||
} | ||
}, | ||
"defaultConfiguration": "development" | ||
}, | ||
"extract-i18n": { | ||
"executor": "@angular-devkit/build-angular:extract-i18n", | ||
"options": { | ||
"buildTarget": "spin-cycle-client:build" | ||
} | ||
}, | ||
"lint": { | ||
"executor": "@nx/eslint:lint" | ||
}, | ||
"test": { | ||
"executor": "@nx/vite:test", | ||
"outputs": ["{options.reportsDirectory}"], | ||
"options": { | ||
"reportsDirectory": "../../coverage/apps/spin-cycle-client" | ||
} | ||
}, | ||
"serve-static": { | ||
"executor": "@nx/web:file-server", | ||
"options": { | ||
"buildTarget": "spin-cycle-client:build", | ||
"staticFilePath": "dist/apps/spin-cycle-client/browser", | ||
"spa": true | ||
} | ||
} | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<main class="main"> | ||
<div class="content"> | ||
@if (!authenticated()) { | ||
<a [href]="authUrl">Login</a> | ||
} | ||
</div> | ||
</main> | ||
|
||
<router-outlet /> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
|
||
import { AppComponent } from './app.component'; | ||
|
||
describe('AppComponent', () => { | ||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [AppComponent], | ||
}).compileComponents(); | ||
}); | ||
|
||
it('should create the app', () => { | ||
const fixture = TestBed.createComponent(AppComponent); | ||
const app = fixture.componentInstance; | ||
expect(app).toBeTruthy(); | ||
}); | ||
|
||
it(`should have the 'spin-cycle' title`, () => { | ||
const fixture = TestBed.createComponent(AppComponent); | ||
const app = fixture.componentInstance; | ||
expect(app.title).toEqual('spin-cycle'); | ||
}); | ||
|
||
it('should render title', () => { | ||
const fixture = TestBed.createComponent(AppComponent); | ||
fixture.detectChanges(); | ||
const compiled = fixture.nativeElement as HTMLElement; | ||
expect(compiled.querySelector('h1')?.textContent).toContain('Hello, spin-cycle'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Component, OnInit, Signal, inject } from '@angular/core'; | ||
import { RouterOutlet } from '@angular/router'; | ||
|
||
import { AuthService } from './auth/auth.service'; | ||
|
||
@Component({ | ||
selector: 'sc-root', | ||
standalone: true, | ||
imports: [RouterOutlet], | ||
templateUrl: './app.component.html', | ||
styleUrl: './app.component.scss', | ||
}) | ||
export class AppComponent implements OnInit { | ||
private readonly authService: AuthService = inject(AuthService); | ||
|
||
public readonly authUrl: string = this.authService.authUrl; | ||
public readonly authenticated: Signal<boolean> = this.authService.authenticated; | ||
|
||
ngOnInit(): void { | ||
this.authService.restoreToken(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { provideHttpClient, withInterceptors } from '@angular/common/http'; | ||
import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core'; | ||
import { provideRouter } from '@angular/router'; | ||
|
||
import { routes } from './app.routes'; | ||
import { authInterceptor } from './auth/auth.interceptor'; | ||
|
||
export const appConfig: ApplicationConfig = { | ||
providers: [ | ||
provideZoneChangeDetection({ eventCoalescing: true }), | ||
provideRouter(routes), | ||
provideHttpClient(withInterceptors([authInterceptor])), | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Routes } from '@angular/router'; | ||
|
||
import { AuthComponent } from './auth/auth.component'; | ||
import { AuthGuard } from './auth/auth.guard'; | ||
import { UnauthGuard } from './auth/unauth.guard'; | ||
import { HistoryComponent } from './history/history.component'; | ||
import { SettingsComponent } from './settings/settings.component'; | ||
|
||
export const routes: Routes = [ | ||
{ | ||
path: 'auth', | ||
component: AuthComponent, | ||
canActivate: [UnauthGuard], | ||
}, | ||
{ | ||
path: 'settings', | ||
component: SettingsComponent, | ||
canActivate: [AuthGuard], | ||
}, | ||
{ | ||
path: 'history', | ||
component: HistoryComponent, | ||
canActivate: [AuthGuard], | ||
}, | ||
]; |
Empty file.
Empty file.
Oops, something went wrong.