Skip to content

Commit 27416b9

Browse files
authored
Initial commit
0 parents  commit 27416b9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+1661
-0
lines changed

.changeset/fast-taxis-begin.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@fake-scope/fake-pkg": patch
3+
---
4+
5+
fix: enable fetch

.editorconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Editor configuration, see http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
indent_style = space
7+
indent_size = 2
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
max_line_length = off
13+
trim_trailing_whitespace = false

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

.eslintrc.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"root": true,
3+
"ignorePatterns": ["**/*"],
4+
"plugins": ["@nx"],
5+
"overrides": [
6+
{
7+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
8+
"rules": {
9+
"@nx/enforce-module-boundaries": [
10+
"error",
11+
{
12+
"enforceBuildableLibDependency": true,
13+
"allow": [],
14+
"depConstraints": [
15+
{
16+
"sourceTag": "*",
17+
"onlyDependOnLibsWithTags": ["*"]
18+
}
19+
]
20+
}
21+
]
22+
}
23+
},
24+
{
25+
"files": ["*.ts", "*.tsx"],
26+
"extends": ["plugin:@nx/typescript"],
27+
"rules": {}
28+
},
29+
{
30+
"files": ["*.js", "*.jsx"],
31+
"extends": ["plugin:@nx/javascript"],
32+
"rules": {}
33+
},
34+
{
35+
"files": ["*.spec.ts", "*.spec.tsx", "*.spec.js", "*.spec.jsx"],
36+
"env": {
37+
"jest": true
38+
},
39+
"rules": {}
40+
}
41+
]
42+
}

.github/workflows/ci.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
permissions:
10+
actions: read
11+
contents: read
12+
13+
jobs:
14+
main:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- uses: oven-sh/setup-bun@v1
22+
with:
23+
bun-version: latest
24+
25+
- run: bun install --no-cache
26+
- uses: nrwl/nx-set-shas@v4
27+
28+
- name: Install Playwright Browsers
29+
run: npx playwright install --with-deps
30+
31+
- run: bun nx affected -t lint test build
32+
- run: bun nx affected --parallel 1 -t e2e-ci
33+
- uses: actions/upload-artifact@v4
34+
if: ${{ !cancelled() }}
35+
with:
36+
name: playwright-report
37+
path: dist/.playwright/apps/
38+
retention-days: 30

.gitignore

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# See http://help.github.com/ignore-files/ for more about ignoring files.
2+
3+
# compiled output
4+
dist
5+
tmp
6+
/out-tsc
7+
8+
# dependencies
9+
node_modules
10+
11+
# IDEs and editors
12+
/.idea
13+
.project
14+
.classpath
15+
.c9/
16+
*.launch
17+
.settings/
18+
*.sublime-workspace
19+
20+
# IDE - VSCode
21+
.vscode/*
22+
!.vscode/settings.json
23+
!.vscode/tasks.json
24+
!.vscode/launch.json
25+
!.vscode/extensions.json
26+
27+
# misc
28+
/.sass-cache
29+
/connect.lock
30+
/coverage
31+
/libpeerconnection.log
32+
npm-debug.log
33+
yarn-error.log
34+
testem.log
35+
/typings
36+
37+
# System Files
38+
.DS_Store
39+
Thumbs.db
40+
41+
.nx/cache
42+
.angular

.prettierignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Add files here to ignore them from prettier formatting
2+
/dist
3+
/coverage
4+
/.nx/cache
5+
.angular

.prettierrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"singleQuote": true
3+
}

.vscode/extensions.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"recommendations": [
3+
"nrwl.angular-console",
4+
"esbenp.prettier-vscode",
5+
"firsttris.vscode-jest-runner",
6+
"ms-playwright.playwright"
7+
]
8+
}

README.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# Project README
2+
3+
## Project Overview
4+
5+
This project is a Angular (With SSR) + Nestjs monorepo using Nx. It is a full-stack application that demonstrates how to structure and manage frontend and backend applications within a single Nx workspace.
6+
7+
## TODO
8+
Feel free to contribute to this project by creating a pull request.
9+
10+
- [ ] Check on how to build for bun runtime
11+
- [ ] Pre rendering routes doesn't spin up the server, so the HTTP calls are not made.
12+
- [ ] Create a material included starter
13+
14+
## Directory Structure
15+
16+
The directory structure of this Nx monorepo is organized as follows:
17+
18+
### Apps
19+
20+
- **apps/app**: This is the main Angular application with SSR enabled.
21+
- **apps/api**: This directory is used for running the backend server during development.
22+
23+
### Libs
24+
25+
- **libs/backend/root**: This directory contains the entry point for the backend services. It includes necessary configurations and files to initialize and run the backend application.
26+
- **libs/frontend/root**: This directory contains the entry point for the frontend services. It includes necessary configurations and files to initialize and run the frontend application.
27+
28+
## Getting Started
29+
30+
### Prerequisites
31+
32+
Ensure you have the following installed on your machine:
33+
34+
- Node.js (latest LTS version recommended)
35+
- Bun
36+
- Nx CLI
37+
38+
### Installation
39+
40+
1. Clone the repository:
41+
42+
```bash
43+
git clone <repository-url>
44+
cd <repository-name>
45+
```
46+
47+
2. Install the dependencies:
48+
```bash
49+
bun install
50+
```
51+
52+
### Running the Applications
53+
54+
To run the application:
55+
56+
```bash
57+
bun start
58+
```
59+
This will start the development server and the application will be available at `http://localhost:4200`.
60+
61+
62+
### Building the Applications
63+
64+
#### Build Frontend
65+
66+
To build the Angular application for production:
67+
68+
```bash
69+
bun run build
70+
```
71+
72+
To run the Application:
73+
74+
```bash
75+
node dist/apps/app/server/server.mjs
76+
```
77+
78+
*NOTE: I'm still looking into running this with bun.*
79+
80+
### Testing
81+
82+
#### Running Unit Tests
83+
84+
To run unit tests:
85+
86+
```bash
87+
nx run-many -t test
88+
```
89+
90+
#### Running End-to-End Tests
91+
92+
To run end-to-end tests:
93+
94+
```bash
95+
nx e2e app-e2e
96+
```
97+
98+

apps/api/.eslintrc.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"extends": ["../../.eslintrc.json"],
3+
"ignorePatterns": ["!**/*"],
4+
"overrides": [
5+
{
6+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
7+
"rules": {}
8+
},
9+
{
10+
"files": ["*.ts", "*.tsx"],
11+
"rules": {}
12+
},
13+
{
14+
"files": ["*.js", "*.jsx"],
15+
"rules": {}
16+
}
17+
]
18+
}

apps/api/jest.config.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* eslint-disable */
2+
export default {
3+
displayName: 'api',
4+
preset: '../../jest.preset.js',
5+
testEnvironment: 'node',
6+
transform: {
7+
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
8+
},
9+
moduleFileExtensions: ['ts', 'js', 'html'],
10+
coverageDirectory: '../../coverage/apps/api',
11+
};

apps/api/project.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "api",
3+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
4+
"sourceRoot": "apps/api/src",
5+
"projectType": "application",
6+
"tags": ["scope:app"],
7+
"targets": {
8+
"serve": {
9+
"executor": "@nx/js:node",
10+
"defaultConfiguration": "development",
11+
"options": {
12+
"buildTarget": "api:build"
13+
},
14+
"configurations": {
15+
"development": {
16+
"buildTarget": "api:build:development"
17+
},
18+
"production": {
19+
"buildTarget": "api:build:production"
20+
}
21+
}
22+
},
23+
"test": {
24+
"executor": "@nx/jest:jest",
25+
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
26+
"options": {
27+
"jestConfig": "apps/api/jest.config.ts"
28+
}
29+
}
30+
}
31+
}

apps/api/src/main.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* This is not a production server yet!
3+
* This is only a minimal backend to get started.
4+
*/
5+
6+
import { Logger } from '@nestjs/common';
7+
import { NestFactory } from '@nestjs/core';
8+
9+
import { AppModule } from '@app/backend-root';
10+
11+
async function bootstrap() {
12+
const app = await NestFactory.create(AppModule);
13+
const globalPrefix = 'api';
14+
app.setGlobalPrefix(globalPrefix);
15+
const port = process.env.PORT || 3000;
16+
await app.listen(port);
17+
Logger.log(
18+
`🚀 Application is running on: http://localhost:${port}/${globalPrefix}`,
19+
);
20+
}
21+
22+
bootstrap();

apps/api/tsconfig.app.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "../../dist/out-tsc",
5+
"module": "commonjs",
6+
"types": ["node"],
7+
"emitDecoratorMetadata": true,
8+
"target": "es2021"
9+
},
10+
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"],
11+
"include": ["src/**/*.ts"]
12+
}

apps/api/tsconfig.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"extends": "../../tsconfig.base.json",
3+
"files": [],
4+
"include": [],
5+
"references": [
6+
{
7+
"path": "./tsconfig.app.json"
8+
},
9+
{
10+
"path": "./tsconfig.spec.json"
11+
}
12+
],
13+
"compilerOptions": {
14+
"esModuleInterop": true
15+
}
16+
}

apps/api/tsconfig.spec.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "../../dist/out-tsc",
5+
"module": "commonjs",
6+
"types": ["jest", "node"]
7+
},
8+
"include": [
9+
"jest.config.ts",
10+
"src/**/*.test.ts",
11+
"src/**/*.spec.ts",
12+
"src/**/*.d.ts"
13+
]
14+
}

0 commit comments

Comments
 (0)