essaye de faire foncitonner un bouton

This commit is contained in:
batche
2022-11-12 10:55:20 +01:00
parent a77b9e99dc
commit 568af62330
33 changed files with 3520 additions and 113 deletions

View File

@@ -3,15 +3,10 @@ DOCKERCOMPOSEPATH=./srcs/docker-compose.yml
#dev allow hot reload.
dev:
sed -i 's/production/development/g' ./srcs/.env
docker compose -f ${DOCKERCOMPOSEPATH} up -d --build dev
@make start_dev
docker compose -f ${DOCKERCOMPOSEPATH} up -d --build
@make start
@docker ps
debug:
sed -i 's/production/development/g' ./srcs/.env
docker compose -f ${DOCKERCOMPOSEPATH} up -d --build debug
@make start_debug
@docker ps
#prod only the needed files ares presents inside the container
prod:
@@ -20,9 +15,13 @@ prod:
@make start_prod
@docker ps
start:
docker compose -f ${DOCKERCOMPOSEPATH} start
docker logs --follow nestjs_api_back_dev
start_dev:
docker compose -f ${DOCKERCOMPOSEPATH} start dev
docker logs --follow nestjs_api_dev
docker logs --follow nestjs_api_back_dev
start_debug:
docker compose -f ${DOCKERCOMPOSEPATH} start debug

View File

@@ -1,14 +1,12 @@
services:
dev:
container_name: nestjs_api_dev
image: nestjs_api_dev
backend_dev:
container_name: nestjs_api_back_dev
image: nestjs_api_back_dev
build:
context: ./requirements/nestjs
target: development
dockerfile: Dockerfile
command: npm run start:dev
ports:
- 3000:3000
networks:
- transcendance_network
volumes:
@@ -23,35 +21,74 @@ services:
- postgresql
- redis
prod:
container_name: nestjs_api_prod
image: nestjs_api_prod
# backend_prod:
# container_name: nestjs_api_back_prod
# image: nestjs_api_back_prod
# build:
# context: ./requirements/nestjs
# target: production
# dockerfile: Dockerfile
# command: npm run start:prod
# ports:
# - 3000:3000
# networks:
# - transcendance_network
# volumes:
# - data_nest_back:/usr/src/app
# - /usr/src/app/node_modules
# restart: unless-stopped
# env_file:
# - .env
# environment:
# NODE_ENV: "${NODE_ENV}"
# depends_on:
# - postgresql
# - redis
frontend_dev:
container_name: nestjs_api_front_dev
image: nestjs_api_front_dev
build:
context: ./requirements/nestjs
target: production
context: ./requirements/svelte
target: development
dockerfile: Dockerfile
command: npm run start:prod
ports:
- 3000:3000
command: npm run dev
networks:
- transcendance_network
volumes:
- data_nest_back:/usr/src/app
- ./requirements/svelte/api_front:/usr/src/app
- /usr/src/app/node_modules
restart: unless-stopped
env_file:
- .env
environment:
NODE_ENV: "${NODE_ENV}"
restart: unless-stopped
depends_on:
- postgresql
- redis
- backend_dev
nginx:
container_name: nginx
build:
context: ./requirements/nginx
dockerfile: Dockerfile
ports:
- 8080:8080
networks:
- transcendance_network
restart: unless-stopped
depends_on:
- backend_dev
- frontend_dev
- postgresql
- redis
postgresql:
container_name: nestjs_postgresql
image: postgres
ports:
- 5432:5432
# ports:
# - 5432:5432
networks:
- transcendance_network
volumes:

View File

@@ -10,31 +10,33 @@ COPY --chown=node:node ./api_back/ ./
USER node
FROM node:19-alpine AS build
# FROM node:19-alpine AS build
WORKDIR /usr/src/app
# WORKDIR /usr/src/app
COPY --chown=node:node ./api_back/package*.json ./
# COPY --chown=node:node ./api_back/package*.json ./
COPY --chown=node:node --from=development /usr/src/app/node_modules ./node_modules
# COPY --chown=node:node --from=development /usr/src/app/node_modules ./node_modules
COPY --chown=node:node ./api_back/ ./
# COPY --chown=node:node ./api_back/ ./
RUN npm run build
# RUN npm run build
ENV NODE_ENV production
# ENV NODE_ENV production
RUN npm ci --only=production && npm cache clean --force
# RUN npm ci --only=production && npm cache clean --force
USER node
# USER node
FROM node:19-alpine AS production
# FROM node:19-alpine AS production
WORKDIR /usr/src/app
# WORKDIR /usr/src/app
COPY --chown=node:node --from=build /usr/src/app/node_modules ./node_modules
COPY --chown=node:node --from=build /usr/src/app/dist ./dist
# COPY --chown=node:node --from=build /usr/src/app/node_modules ./node_modules
# COPY --chown=node:node --from=build /usr/src/app/dist ./dist
USER node
# USER node
CMD [ "node", "dist/main.js" ]
ENV HOST=0.0.0.0
CMD [ "node", "run", "start:dev" ]

View File

@@ -6,8 +6,10 @@ export declare class AuthenticationController {
private authService;
private userService;
constructor(authService: AuthenticationService, userService: UsersService);
login(): void;
redirect(response: Response, request: any): Promise<void>;
login(response: Response): {
msg: string;
};
redirect(response: Response, request: any): Promise<any>;
status(): string;
logout(request: any): {
msg: string;

View File

@@ -23,12 +23,13 @@ let AuthenticationController = class AuthenticationController {
this.authService = authService;
this.userService = userService;
}
login() {
login(response) {
console.log('ON EST DANS LOGIN AUTH CONTROLLER');
return;
return { msg: 'You are now logged in' };
}
async redirect(response, request) {
response.sendStatus(200);
console.log('ON EST DANS REDIRECT AUTH CONTROLLER' + request.user);
return request.user;
}
status() {
return 'status';
@@ -54,9 +55,11 @@ let AuthenticationController = class AuthenticationController {
};
__decorate([
(0, common_1.Get)(),
(0, common_1.Options)(),
(0, common_1.UseGuards)(_42guards_1.FortyTwoAuthGuard),
__param(0, (0, common_1.Res)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", void 0)
], AuthenticationController.prototype, "login", null);
__decorate([

View File

@@ -1 +1 @@
{"version":3,"file":"authentication.controller.js","sourceRoot":"","sources":["../../../src/auth/42/authentication.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAyG;AACzG,iDAAyE;AACzE,qEAAiE;AAEjE,4CAAyC;AACzC,6DAAuD;AAGhD,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IAEpC,YAAoB,WAAkC,EAC3C,WAAyB;QADhB,gBAAW,GAAX,WAAW,CAAuB;QAC3C,gBAAW,GAAX,WAAW,CAAc;IAC9B,CAAC;IAQP,KAAK;QACJ,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC;QACjD,OAAQ;IACT,CAAC;IASK,AAAN,KAAK,CAAC,QAAQ,CAAQ,QAAmB,EAAS,OAAO;QACxD,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;IASD,MAAM;QACL,OAAO,QAAQ,CAAC;IACjB,CAAC;IAOD,MAAM,CAAQ,OA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C,6BAAiB,CAAC;;;;sDAG5B;AAMD;IAAC,IAAA,YAAG,EAAC,QAAQ,CAAC;IACN,WAAA,IAAA,YAAG,GAAE,CAAA;;;;sDAIZ;AAIK;IAFL,IAAA,aAAI,EAAC,cAAc,CAAC;IACpB,IAAA,kBAAS,EAAC,6BAAiB,CAAC;IACb,WAAA,IAAA,YAAG,GAAE,CAAA;IAAW,WAAA,IAAA,YAAG,GAAE,CAAA;;;;wDAIpC;AAIK;IAFL,IAAA,aAAI,EAAC,aAAa,CAAC;IACnB,IAAA,kBAAS,EAAC,6BAAiB,CAAC;IACf,WAAA,IAAA,YAAG,GAAE,CAAA;IAAW,WAAA,IAAA,aAAI,GAAE,CAAA;;6CAAe,mBAAQ;;sDAQ1D;AApEW,wBAAwB;IADpC,IAAA,mBAAU,EAAC,MAAM,CAAC;qCAGe,8CAAqB;QAC9B,4BAAY;GAHxB,wBAAwB,CAqEpC;AArEY,4DAAwB"}
{"version":3,"file":"authentication.controller.js","sourceRoot":"","sources":["../../../src/auth/42/authentication.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAkH;AAClH,iDAAyE;AACzE,qEAAiE;AAEjE,4CAAyC;AACzC,6DAAuD;AAGhD,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IAEpC,YAAoB,WAAkC,EAC3C,WAAyB;QADhB,gBAAW,GAAX,WAAW,CAAuB;QAC3C,gBAAW,GAAX,WAAW,CAAc;IAC9B,CAAC;IASP,KAAK,CAAQ,QAAmB;QAC/B,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC;QACjD,OAAO,EAAC,GAAG,EAAG,uBAAuB,EAAC,CAAC;IACxC,CAAC;IASK,AAAN,KAAK,CAAC,QAAQ,CAAQ,QAAmB,EAAS,OAAO;QACxD,OAAO,CAAC,GAAG,CAAC,sCAAsC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QACnE,OAAO,OAAO,CAAC,IAAI,CAAC;IACrB,CAAC;I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GAAE,CAAA;IAAuB,WAAA,IAAA,YAAG,GAAE,CAAA;;;;wDAGhD;AAOD;IAAC,IAAA,YAAG,EAAC,QAAQ,CAAC;IACb,IAAA,kBAAS,EAAC,6BAAiB,CAAC;;;;sDAG5B;AAMD;IAAC,IAAA,YAAG,EAAC,QAAQ,CAAC;IACN,WAAA,IAAA,YAAG,GAAE,CAAA;;;;sDAIZ;AAIK;IAFL,IAAA,aAAI,EAAC,cAAc,CAAC;IACpB,IAAA,kBAAS,EAAC,6BAAiB,CAAC;IACb,WAAA,IAAA,YAAG,GAAE,CAAA;IAAW,WAAA,IAAA,YAAG,GAAE,CAAA;;;;wDAIpC;AAIK;IAFL,IAAA,aAAI,EAAC,aAAa,CAAC;IACnB,IAAA,kBAAS,EAAC,6BAAiB,CAAC;IACf,WAAA,IAAA,YAAG,GAAE,CAAA;IAAW,WAAA,IAAA,aAAI,GAAE,CAAA;;6CAAe,mBAAQ;;sDAQ1D;AAtEW,wBAAwB;IADpC,IAAA,mBAAU,EAAC,MAAM,CAAC;qCAGe,8CAAqB;QAC9B,4BAAY;GAHxB,wBAAwB,CAuEpC;AAvEY,4DAAwB"}

View File

@@ -1,2 +0,0 @@
export declare class AuthModule {
}

View File

@@ -1,22 +0,0 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AuthModule = void 0;
const common_1 = require("@nestjs/common");
const auth_service_1 = require("./auth.service");
const users_module_1 = require("../users/users.module");
let AuthModule = class AuthModule {
};
AuthModule = __decorate([
(0, common_1.Module)({
imports: [users_module_1.UsersModule],
providers: [auth_service_1.AuthService],
})
], AuthModule);
exports.AuthModule = AuthModule;
//# sourceMappingURL=auth.module.js.map

View File

@@ -1 +0,0 @@
{"version":3,"file":"auth.module.js","sourceRoot":"","sources":["../../src/auth/auth.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,iDAA6C;AAC7C,wDAAqD;AAM9C,IAAM,UAAU,GAAhB,MAAM,UAAU;CAAG,CAAA;AAAb,UAAU;IAJtB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,0BAAW,CAAC;QACtB,SAAS,EAAE,CAAC,0BAAW,CAAC;KACzB,CAAC;GACW,UAAU,CAAG;AAAb,gCAAU"}

View File

@@ -1,6 +0,0 @@
import { UsersService } from '../users/users.service';
export declare class AuthService {
private usersService;
constructor(usersService: UsersService);
validateUser(username: string, pass: string): Promise<any>;
}

View File

@@ -1,28 +0,0 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AuthService = void 0;
const common_1 = require("@nestjs/common");
const users_service_1 = require("../users/users.service");
let AuthService = class AuthService {
constructor(usersService) {
this.usersService = usersService;
}
async validateUser(username, pass) {
return null;
}
};
AuthService = __decorate([
(0, common_1.Injectable)(),
__metadata("design:paramtypes", [users_service_1.UsersService])
], AuthService);
exports.AuthService = AuthService;
//# sourceMappingURL=auth.service.js.map

View File

@@ -1 +0,0 @@
{"version":3,"file":"auth.service.js","sourceRoot":"","sources":["../../src/auth/auth.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,0DAAsD;AAG/C,IAAM,WAAW,GAAjB,MAAM,WAAW;IACvB,YAAqB,YAA0B;QAA1B,iBAAY,GAAZ,YAAY,CAAc;IAAG,CAAC;IAEnD,KAAK,CAAC,YAAY,CAAC,QAAgB,EAAE,IAAY;QAChD,OAAO,IAAI,CAAC;IACb,CAAC;CACD,CAAA;AANY,WAAW;IADvB,IAAA,mBAAU,GAAE;qCAEuB,4BAAY;GADnC,WAAW,CAMvB;AANY,kCAAW"}

View File

@@ -1 +1 @@
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;AAAA,uCAA2C;AAC3C,2CAAgD;AAChD,6CAAyC;AACzC,2CAA2C;AAC3C,qCAAqC;AACrC,+BAA+B;AAC/B,8CAA8C;AAE9C,KAAK,UAAU,SAAS;IACvB,MAAM,GAAG,GAAG,MAAM,kBAAW,CAAC,MAAM,CAAC,sBAAS,CAAC,CAAC;IAChD,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,IAAI,CAAC;IACtC,MAAM,MAAM,GAAG,KAAK,CAAC,YAAY,CAChC;QACC,MAAM,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE;QAChF,UAAU,EAAE,IAAI;KAChB,CACD,CAAC;IACF,MAAM,CAAC,OAAO,EAAE,CAAC;IACjB,MAAM,UAAU,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;IACzC,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;QACzB,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;IAIH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,CAAC"}

File diff suppressed because one or more lines are too long

View File

@@ -1,4 +1,4 @@
import { Controller, Get, Res, UseGuards, Req, Post, UnauthorizedException, Body } from '@nestjs/common';
import { Controller, Get, Res, UseGuards, Req, Post, UnauthorizedException, Body, Options } from '@nestjs/common';
import { AuthenticateGuard, FortyTwoAuthGuard } from './guards/42guards';
import { AuthenticationService } from './authentication.service';
import { Response } from 'express';
@@ -17,10 +17,11 @@ export class AuthenticationController {
* Route pour l'autentification des utilisateurs
*/
@Get()
@Options()
@UseGuards(FortyTwoAuthGuard)
login() {
login(@Res() response : Response) {
console.log('ON EST DANS LOGIN AUTH CONTROLLER');
return ;
return {msg : 'You are now logged in'};
}
/**
@@ -31,7 +32,8 @@ export class AuthenticationController {
@Get('redirect')
@UseGuards(FortyTwoAuthGuard)
async redirect(@Res() response : Response, @Req() request) {
response.sendStatus(200);
console.log('ON EST DANS REDIRECT AUTH CONTROLLER' + request.user);
return request.user;
}
/**

View File

@@ -8,6 +8,12 @@ import * as connectRedis from 'connect-redis';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
// app.enableCors({
// allowedHeaders: 'Origin, X-Requested-With, Content-Type, Accept, Authorization, Access-Control-Allow-Credentials, Access-Control-Allow-Origin',
// origin: ['http://transcendance:8080','http://127.0.0.1:8080', 'https://api.intra.42.fr',],
// credentials: true,
// methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS', 'PATCH'],
// });
const port = process.env.PORT || 3001;
const client = redis.createClient(
{

View File

@@ -0,0 +1,3 @@
FROM nginx:alpine
COPY ./conf/default.conf /etc/nginx/conf.d/default.conf

View File

@@ -0,0 +1,34 @@
server {
listen 8080 default_server;
listen [::]:8080 default_server;
server_name transcendance;
location /api/v2 {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://backend_dev:3000;
}
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://frontend_dev:8080;
}
}
server {
listen 35729 default_server;
listen [::]:35729 default_server;
server_name transcendance;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://frontend_dev:35729;
}
}

View File

@@ -0,0 +1,42 @@
FROM node:19-alpine AS development
WORKDIR /usr/src/app
COPY --chown=node:node ./api_front/package*.json ./
RUN npm ci
COPY --chown=node:node ./api_front/ ./
USER node
# FROM node:19-alpine AS build
# WORKDIR /usr/src/app
# COPY --chown=node:node ./api_front/package*.json ./
# COPY --chown=node:node --from=development /usr/src/app/node_modules ./node_modules
# COPY --chown=node:node ./api_front/ ./
# RUN npm run build
# ENV NODE_ENV production
# RUN npm ci --only=production && npm cache clean --force
# USER node
# FROM node:19-alpine AS production
# WORKDIR /usr/src/app
# COPY --chown=node:node --from=build /usr/src/app/node_modules ./node_modules
# COPY --chown=node:node --from=build /usr/src/app/dist ./dist
# USER node
ENV HOST=0.0.0.0
CMD [ "node", "run", "dev"]

View File

@@ -0,0 +1,4 @@
/node_modules/
/public/build/
.DS_Store

View File

@@ -0,0 +1,107 @@
# This repo is no longer maintained. Consider using `npm init vite` and selecting the `svelte` option or — if you want a full-fledged app framework and don't mind using pre-1.0 software — use [SvelteKit](https://kit.svelte.dev), the official application framework for Svelte.
---
# svelte app
This is a project template for [Svelte](https://svelte.dev) apps. It lives at https://github.com/sveltejs/template.
To create a new project based on this template using [degit](https://github.com/Rich-Harris/degit):
```bash
npx degit sveltejs/template svelte-app
cd svelte-app
```
*Note that you will need to have [Node.js](https://nodejs.org) installed.*
## Get started
Install the dependencies...
```bash
cd svelte-app
npm install
```
...then start [Rollup](https://rollupjs.org):
```bash
npm run dev
```
Navigate to [localhost:8080](http://localhost:8080). You should see your app running. Edit a component file in `src`, save it, and reload the page to see your changes.
By default, the server will only respond to requests from localhost. To allow connections from other computers, edit the `sirv` commands in package.json to include the option `--host 0.0.0.0`.
If you're using [Visual Studio Code](https://code.visualstudio.com/) we recommend installing the official extension [Svelte for VS Code](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode). If you are using other editors you may need to install a plugin in order to get syntax highlighting and intellisense.
## Building and running in production mode
To create an optimised version of the app:
```bash
npm run build
```
You can run the newly built app with `npm run start`. This uses [sirv](https://github.com/lukeed/sirv), which is included in your package.json's `dependencies` so that the app will work when you deploy to platforms like [Heroku](https://heroku.com).
## Single-page app mode
By default, sirv will only respond to requests that match files in `public`. This is to maximise compatibility with static fileservers, allowing you to deploy your app anywhere.
If you're building a single-page app (SPA) with multiple routes, sirv needs to be able to respond to requests for *any* path. You can make it so by editing the `"start"` command in package.json:
```js
"start": "sirv public --single"
```
## Using TypeScript
This template comes with a script to set up a TypeScript development environment, you can run it immediately after cloning the template with:
```bash
node scripts/setupTypeScript.js
```
Or remove the script via:
```bash
rm scripts/setupTypeScript.js
```
If you want to use `baseUrl` or `path` aliases within your `tsconfig`, you need to set up `@rollup/plugin-alias` to tell Rollup to resolve the aliases. For more info, see [this StackOverflow question](https://stackoverflow.com/questions/63427935/setup-tsconfig-path-in-svelte).
## Deploying to the web
### With [Vercel](https://vercel.com)
Install `vercel` if you haven't already:
```bash
npm install -g vercel
```
Then, from within your project folder:
```bash
cd public
vercel deploy --name my-project
```
### With [surge](https://surge.sh/)
Install `surge` if you haven't already:
```bash
npm install -g surge
```
Then, from within your project folder:
```bash
npm run build
surge public my-project.surge.sh
```

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,33 @@
{
"name": "svelte-app",
"version": "1.0.0",
"private": true,
"scripts": {
"build": "rollup -c",
"dev": "rollup -c -w",
"start": "sirv public --no-clear",
"check": "svelte-check --tsconfig ./tsconfig.json"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^17.0.0",
"@rollup/plugin-node-resolve": "^11.0.0",
"@rollup/plugin-typescript": "^8.0.0",
"@tsconfig/svelte": "^2.0.0",
"rollup": "^2.3.4",
"rollup-plugin-css-only": "^3.1.0",
"rollup-plugin-livereload": "^2.0.0",
"rollup-plugin-svelte": "^7.0.0",
"rollup-plugin-terser": "^7.0.0",
"svelte": "^3.0.0",
"svelte-check": "^2.0.0",
"svelte-preprocess": "^4.0.0",
"tslib": "^2.0.0",
"typescript": "^4.0.0"
},
"dependencies": {
"axios": "^1.1.3",
"bootstrap": "^5.2.2",
"sirv-cli": "^2.0.0",
"svelte-spa-router": "^3.3.0"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@@ -0,0 +1,4 @@
html {
height: -webkit-fill-available;
}

View File

@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset='utf-8'>
<meta name='viewport' content='width=device-width,initial-scale=1'>
<!-- CSS only -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous">
<title>Svelte app</title>
<link rel='icon' type='image/png' href='/favicon.png'>
<link rel='stylesheet' href='/global.css'>
<link rel='stylesheet' href='/build/bundle.css'>
<script defer src='/build/bundle.js'></script>
</head>
<body>
</body>
</html>

View File

@@ -0,0 +1,83 @@
import svelte from 'rollup-plugin-svelte';
import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
import livereload from 'rollup-plugin-livereload';
import { terser } from 'rollup-plugin-terser';
import sveltePreprocess from 'svelte-preprocess';
import typescript from '@rollup/plugin-typescript';
import css from 'rollup-plugin-css-only';
const production = !process.env.ROLLUP_WATCH;
function serve() {
let server;
function toExit() {
if (server) server.kill(0);
}
return {
writeBundle() {
if (server) return;
server = require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], {
stdio: ['ignore', 'inherit', 'inherit'],
shell: true
});
process.on('SIGTERM', toExit);
process.on('exit', toExit);
}
};
}
export default {
input: 'src/main.ts',
output: {
sourcemap: true,
format: 'iife',
name: 'app',
file: 'public/build/bundle.js'
},
plugins: [
svelte({
preprocess: sveltePreprocess({ sourceMap: !production }),
compilerOptions: {
// enable run-time checks when not in production
dev: !production
}
}),
// we'll extract any component CSS out into
// a separate file - better for performance
css({ output: 'bundle.css' }),
// If you have external dependencies installed from
// npm, you'll most likely need these plugins. In
// some cases you'll need additional configuration -
// consult the documentation for details:
// https://github.com/rollup/plugins/tree/master/packages/commonjs
resolve({
browser: true,
dedupe: ['svelte']
}),
commonjs(),
typescript({
sourceMap: !production,
inlineSources: !production
}),
// In dev mode, call `npm run start` once
// the bundle has been generated
!production && serve(),
// Watch the `public` directory and refresh the
// browser on changes when not in production
!production && livereload('public'),
// If we're building for production (npm run build
// instead of npm run dev), minify
production && terser()
],
watch: {
clearScreen: false
}
};

View File

@@ -0,0 +1,32 @@
<script>
import Login from "./pages/auth/login.svelte";
import Home from "./pages/home/home.svelte";
import Router, {link} from 'svelte-spa-router';
const routes = {
"/": Home,
"/login": Login,
};
</script>
<header class="p-3 text-bg-dark">
<div class="container">
<div
class="d-flex flex-wrap align-items-center justify-content-center justify-content-lg-start">
<ul class="nav col-12 col-lg-auto me-lg-auto mb-2 justify-content-center mb-md-0">
<li>
<a href="/" type="button" class="btn btn-primary">Home</a>
</li>
</ul>
<div class="text-end">
<a href="/login" use:link type="button" class="btn btn-warning">Connexion</a>
</div>
</div>
</div>
</header>
<Router {routes} />

View File

@@ -0,0 +1 @@
/// <reference types="svelte" />

View File

@@ -0,0 +1,10 @@
import App from './App.svelte';
const app = new App({
target: document.body,
props: {
name: 'world'
}
});
export default app;

View File

@@ -0,0 +1,40 @@
<script lang="ts">
import axios from 'axios';
import {push} from 'svelte-spa-router';
$: submit = async() => {
console.log("submit");
const {data} = await axios.get('http://transcendance:8080/api/v2/auth',
{
withCredentials: true,
}
);
if (data.status === "ok") {
push('/');
}
}
</script>
<body>
<main class="form-signin w-100 m-auto">
<button on:click={submit} class="w-100 btn btn-lg btn-primary" type="submit">
Connexion avec prout
</button>
</main>
</body>
<style>
body {
display: flex;
align-items: center;
padding-top: 40px;
padding-bottom: 40px;
}
.form-signin {
max-width: 330px;
padding: 15px;
}
</style>

View File

@@ -0,0 +1,79 @@
<body>
<main class="d-flex flex-nowrap">
<h1 class="visually-hidden">Sidebars examples</h1>
<div class="d-flex flex-column flex-shrink-0 p-3 text-bg-dark" style="width: 280px;">
<a href="/" class="d-flex align-items-center mb-3 mb-md-0 me-md-auto text-white text-decoration-none">
<svg class="bi pe-none me-2" width="40" height="32"><use xlink:href="#bootstrap"/></svg>
<span class="fs-4">Sidebar</span>
</a>
<hr>
<ul class="nav nav-pills flex-column mb-auto">
<li class="nav-item">
<a href="#" class="nav-link active" aria-current="page">
<svg class="bi pe-none me-2" width="16" height="16"><use xlink:href="#home"/></svg>
Home
</a>
</li>
<li>
<a href="#" class="nav-link text-white">
<svg class="bi pe-none me-2" width="16" height="16"><use xlink:href="#speedometer2"/></svg>
Dashboard
</a>
</li>
<li>
<a href="#" class="nav-link text-white">
<svg class="bi pe-none me-2" width="16" height="16"><use xlink:href="#table"/></svg>
Orders
</a>
</li>
<li>
<a href="#" class="nav-link text-white">
<svg class="bi pe-none me-2" width="16" height="16"><use xlink:href="#grid"/></svg>
Products
</a>
</li>
<li>
<a href="#" class="nav-link text-white">
<svg class="bi pe-none me-2" width="16" height="16"><use xlink:href="#people-circle"/></svg>
Customers
</a>
</li>
</ul>
<hr>
<div class="dropdown">
<a href="#" class="d-flex align-items-center text-white text-decoration-none dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
<img src="https://github.com/mdo.png" alt="" width="32" height="32" class="rounded-circle me-2">
<strong>mdo</strong>
</a>
<ul class="dropdown-menu dropdown-menu-dark text-small shadow">
<li><a class="dropdown-item" href="#">New Game</a></li>
<li><a class="dropdown-item" href="#">Leaderboard</a></li>
<li><a class="dropdown-item" href="#">Chat</a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="#">Profile</a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="#">Sign out</a></li>
</ul>
</div>
</div>
</main>
</body>
<style>
body {
min-height: 100vh;
min-height: -webkit-fill-available;
}
main {
height: 100vh;
height: -webkit-fill-available;
max-height: 100vh;
overflow-x: auto;
overflow-y: hidden;
}
.dropdown-toggle { outline: 0; }
</style>

View File

@@ -0,0 +1,6 @@
{
"extends": "@tsconfig/svelte/tsconfig.json",
"include": ["src/**/*"],
"exclude": ["node_modules/*", "__sapper__/*", "public/*"]
}