nothing works, this is a backup

This commit is contained in:
AtHeartEngineer
2023-06-23 00:03:23 +00:00
parent 837851b51f
commit 09fb75d4ca
28 changed files with 9417 additions and 8 deletions

23
.gitignore vendored Normal file
View File

@@ -0,0 +1,23 @@
# Nuxt dev/build outputs
.output
.nuxt
.nitro
.cache
dist
# Node dependencies
node_modules
# Logs
logs
*.log
# Misc
.DS_Store
.fleet
.idea
# Local env files
.env
.env.*
!.env.example

24
PLAN.md
View File

@@ -36,22 +36,30 @@
* Staking by tiers with different rate limits?
* Should messages be ephemeral/temporary? (the last day?)
### Stack?
#### Front End
### Front End
discreetly.chat will be the front end and backend
#### Stack
* Nuxtjs
* websockets
#### Back End
#### Login
* Cryptkeeper
* Metamask
* Walletconnect
* Sismo
* Zupass
### Back End
discreetly.chat will be the front end and backend
stakers.chat will be a standalone backend for eth stakers
#### Stack
* Javascript / Typescript
* Node?
* Libp2p?
* Shorter development cycle
* Dev process is annoying
* One language stack which is nice
* Rust
* Libp2p?
* Long development cycle
* Fast / Solid
* Python
* Library compatibility issues with RLNjs and maybe any other ZK libraries
* I could write it really fast

7
lerna.json Normal file
View File

@@ -0,0 +1,7 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"version": "0.0.0",
"packages": [
"packages/*"
]
}

23
package.json Normal file
View File

@@ -0,0 +1,23 @@
{
"name": "discreetly",
"private": true,
"version": "0.1.0",
"description": "",
"main": "index.js",
"scripts": {},
"keywords": [],
"author": "",
"license": "ISC",
"workspaces": [
"packages/*"
],
"dependencies": {
"typescript": "^5.1.3"
},
"devDependencies": {
"@types/node": "^20.3.1",
"lerna": "^7.0.2",
"rlnjs": "^3.1.0",
"ts-node": "^10.9.1"
}
}

2
packages/frontend/.npmrc Normal file
View File

@@ -0,0 +1,2 @@
shamefully-hoist=true
strict-peer-dependencies=false

View File

@@ -0,0 +1,63 @@
# Nuxt 3 Minimal Starter
Look at the [Nuxt 3 documentation](https://nuxt.com/docs/getting-started/introduction) to learn more.
## Setup
Make sure to install the dependencies:
```bash
# npm
npm install
# pnpm
pnpm install
# yarn
yarn install
```
## Development Server
Start the development server on `http://localhost:3000`:
```bash
# npm
npm run dev
# pnpm
pnpm run dev
# yarn
yarn dev
```
## Production
Build the application for production:
```bash
# npm
npm run build
# pnpm
pnpm run build
# yarn
yarn build
```
Locally preview production build:
```bash
# npm
npm run preview
# pnpm
pnpm run preview
# yarn
yarn preview
```
Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information.

View File

@@ -0,0 +1,89 @@
@import "../../../../node_modules/bootstrap/scss/_functions";
@import "../../../../node_modules/bootstrap/scss/_variables";
@import "../../../../node_modules/bootstrap/scss/_mixins";
// set theme colors
$d-blackish: rgba(0, 0, 0, 0.98);
$d-gray-dark: #212121;
$d-gray-light: rgba(242, 242, 242, 0.6);
$d-white: rgba(255, 255, 255, 1);
$d-whitish: rgb(225, 225, 225);
$d-steel: rgb(108, 149, 153);
$d-neon-green: #59f02b;
$d-green: #19d457;
$d-green-light: #61f291;
$d-green-dark: #198754;
$d-jade: #45a164;
$d-hunter-green: #405c37;
$d-dark-blue: #315db5;
$d-blue: #477eed;
$d-blue-light: #53d3e0;
$d-blue-very-light: #a7f6ff;
$d-violet: #9198e5;
$d-violet-light: #b4bbff;
$d-mauve: #cc71c2;
$d-pink: #bf2c7f;
$d-purple: #b638f5;
$d-sunset: #ff7575;
$d-sunset-light: #ffb585;
$d-orangered: #fa5f5f;
$d-max-red: #de1a1a;
$d-yellow: #fad14b;
$primary: $d-sunset;
$dark: $d-gray-dark;
$theme1: $d-purple;
// bootstrap overrides
$blue: $d-blue;
$indigo: #6610f2;
$purple: $d-purple;
$pink: $d-pink;
$red: $d-max-red;
$orange: $d-sunset;
$yellow: $d-yellow;
$green: $d-green-dark;
$teal: #20c997;
$cyan: $d-blue-light;
$primary: $d-dark-blue;
$secondary: $gray-600;
$success: $green;
$info: $cyan;
$warning: $yellow;
$danger: $red;
$light: $gray-100;
$dark: $gray-900;
// add custom colors to the bootstrap theme
$custom-theme-colors: (
"theme1": $theme1,
"white": $white
);
// fix for bootstrap 5.1 transposing colors
$theme-colors: map-merge($theme-colors, $custom-theme-colors);
$theme-colors-rgb: map-loop($theme-colors, to-rgb, "$value");
// Overwrite bootstrap sass variables (check _variables for all options)
$enable-negative-margins: true;
$enable-cssgrid: true;
$enable-grid-classes: false;
$font-family-base: 'Poppins', sans-serif;
$link-color: $theme1;
$navbar-padding-y: $spacer * .1;
$navbar-light-toggler-border-color: rgba($white, 0);
$navbar-dark-toggler-border-color: rgba($white, 0);
$body-top-padding: $font-size-base + ($line-height-base + $nav-link-padding-y);
body {
padding-top: $body-top-padding;
}
// Finally load bootstrap
@import "../../../../node_modules/bootstrap/scss/bootstrap";
// Load a custom font
@import url('https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,400;0,600;1,400;1,600&display=swap');

View File

@@ -0,0 +1,21 @@
<template>
<footer class="d-flex flex-column flex-sm-row justify-content-around mt-2 py-3 px-2 border-top">
<p class="col-md-4 mb-0 text-body-secondary">© 2023 Privacy and Scaling Explorations</p>
<ul class="nav col-md-4 justify-content-end px-3">
<li class="nav-item">
<NuxtLink to="/" class="nav-link">Home</NuxtLink>
</li>
</ul>
</footer>
</template>
<style>
p {
vertical-align: middle;
}
.nav-link {
padding: 0;
}
</style>

View File

@@ -0,0 +1,26 @@
<template>
<header>
<nav class="navbar fixed-top navbar-dark bg-dark navbar-expand-lg">
<div class="container-fluid">
<a class="navbar-brand" href="#">Discreetly</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarText"
aria-controls="navbarText" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarText">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<NuxtLink to="/" class="nav-link">Home</NuxtLink>
</li>
<li class="nav-item">
<NuxtLink to="/chat" class="nav-link">Chat</NuxtLink>
</li>
<li class="nav-item">
<NuxtLink to="/login" class="nav-link">Login</NuxtLink>
</li>
</ul>
</div>
</div>
</nav>
</header>
</template>

View File

@@ -0,0 +1,20 @@
<template>
<div class="chat-messages">
<div v-for="(message, index) in messages[currentRoom]" :key="index" class="chat-message">
<p>
<strong>{{ message.user }}</strong>: {{ message.text }}
</p>
</div>
</div>
<div class="chat-input">
<input type="text" v-model="newMessage" @keyup.enter="addMessage" placeholder="Type your message here">
</div>
</template>
<script setup>
</script>
<script>
</script>

View File

@@ -0,0 +1,11 @@
<template>
<ul class="list-group">
<li v-for="(room, index) in rooms" :key="index" class="list-group-item" :class="{ active: currentRoom === room }"
@click="switchRoom(room)">
{{ room }}
</li>
</ul>
</template>
<script>
</script>

View File

@@ -0,0 +1 @@
Discreetly Description

View File

@@ -0,0 +1,9 @@
<template>
<div class="d-flex flex-column h-100">
<AppHeader />
<main class="align-items-center">
<slot />
</main>
<AppFooter />
</div>
</template>

View File

@@ -0,0 +1,11 @@
function isAuthenticated() {
return true;
}
export default defineNuxtRouteMiddleware((to, from) => {
// isAuthenticated() is an example method verifying if a user is authenticated
if (isAuthenticated() === false) {
return navigateTo('/login');
}
});

View File

@@ -0,0 +1,6 @@
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
devtools: { enabled: true },
modules: ['@nuxtjs/device'],
css: ['~/assets/scss/main.scss']
});

View File

@@ -0,0 +1,26 @@
{
"name": "discreetly-frontend",
"private": true,
"version": "0.1.0",
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare"
},
"devDependencies": {
"@nuxt/devtools": "latest",
"@nuxtjs/device": "^3.1.0",
"@types/bootstrap": "^5.2.6",
"nuxt": "^3.5.2",
"postcss": "^8.4.24",
"postcss-loader": "^7.3.3",
"sass": "^1.63.5",
"sass-loader": "^13.3.2"
},
"dependencies": {
"bootstrap": "^5.3.0",
"socket.io-client": "^4.6.2"
}
}

View File

@@ -0,0 +1,25 @@
<template>
<div id="app" class="container-fluid">
<div class="grid" style="--bs-columns: 3;">
<div class="g-col">
<h3>Chat Rooms</h3>
<ChatRoomList />
</div>
<div class="g-col-2 chat-room h-100">
<ChatRoom></ChatRoom>
</div>
</div>
</div>
</template>
<script setup>
definePageMeta({
middleware: 'auth'
})
</script >
<script>
</script>
<style scoped></style>

View File

@@ -0,0 +1,17 @@
<template>
Index Page
</template>
<style></style>
<script>
import { io } from "socket.io-client";
const socket = io("http://localhost:3001");
socket.emit("test", "hello world test from client");
socket.on("test", (data) => {
console.log(data);
});
socket.on("chat message", (data) => {
console.log(data);
});
socket.emit("chat message", "hello world from client");
</script>

View File

@@ -0,0 +1,22 @@
<template>
<section class="container">
<div class="card m-auto text-center">
<div class="card-header">
<h2 class="h3 mb-3 fw-normal">Please sign in</h2>
</div>
<div class="card-body d-flex flex-column">
<button class="btn btn-primary my-1" type="submit">Cryptkeeper</button>
<button class="btn btn-primary my-1" type="submit">Sismo</button>
<button class="btn btn-primary my-1" type="submit">Wallet Connect</button>
<button class="btn btn-primary my-1" type="submit">Metamask</button>
</div>
</div>
</section>
</template>
<style>
.card {
max-width: 30rem;
}
</style>

View File

@@ -0,0 +1,9 @@
import * as bootstrap from 'bootstrap';
export default defineNuxtPlugin(() => {
return {
provide: {
bootstrap: bootstrap
}
};
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

View File

@@ -0,0 +1,26 @@
{
"name": "discreetly-server",
"version": "0.1.0",
"description": "",
"main": "src/server.ts",
"scripts": {
"build": "tsc ./src/server.ts --outDir ./dist",
"start": "node dist/server.js",
"watch": "tsc ./src/server.ts --outDir ./dist --watch",
"serve": "nodemon -q dist/server.js",
"dev": "concurrently \"npm run watch\" \"npm run serve\""
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"dotenv": "^16.3.1",
"express": "^4.18.2",
"socket.io": "^4.6.2"
},
"devDependencies": {
"@types/express": "^4.17.17",
"concurrently": "^8.2.0",
"nodemon": "^2.0.22"
}
}

View File

@@ -0,0 +1,43 @@
import * as express from 'express';
import { Server } from 'http';
import { Server as SocketIOServer, Socket } from 'socket.io';
const socket_port = 3001;
const http_port = 3002;
const app = express();
const socket_server = new Server(app);
const io = new SocketIOServer(socket_server, {
cors: {
origin: 'http://localhost:3000'
}
});
io.on('connection', (socket: Socket) => {
console.debug('a user connected');
socket.on('chat message', (msg: string) => {
io.emit('chat message', msg);
});
socket.on('test', (msg: string) => {
console.log(msg);
io.emit('test', { received: msg });
});
socket.on('disconnect', () => {
console.log('user disconnected');
});
});
socket_server.listen(socket_port, () => {
console.log(`Socket Server is running at http://localhost:${socket_port}`);
});
app.get('/endpoint', (req, res) => {
res.json({ message: 'Hello, world!' });
});
app.listen(http_port, () => {
console.log(`Http Server is running at http://localhost:${http_port}`);
});

3
tsconfig.json Normal file
View File

@@ -0,0 +1,3 @@
{
"extends": "./packages/frontend/.nuxt/tsconfig.json"
}

8918
yarn.lock Normal file

File diff suppressed because it is too large Load Diff