chore: move files around
This commit is contained in:
parent
5922ff7982
commit
7318cac349
21
.gitignore
vendored
21
.gitignore
vendored
@ -5,7 +5,8 @@
|
||||
**/yarn-error.log
|
||||
**/.history
|
||||
|
||||
/backend/cwd/
|
||||
/backend/keys
|
||||
/backend/images
|
||||
/backend/pacakage.json
|
||||
|
||||
/frontend/dist
|
||||
@ -13,13 +14,13 @@
|
||||
/frontend/out-tsc
|
||||
/frontend/bazel-out
|
||||
|
||||
/frontent/.angular/cache
|
||||
/frontent/**/.sass-cache/
|
||||
/frontent/connect.lock
|
||||
/frontent/coverage
|
||||
/frontent/libpeerconnection.log
|
||||
/frontent/**/testem.log
|
||||
/frontent/typings
|
||||
/frontend/.angular/cache
|
||||
/frontend/**/.sass-cache/
|
||||
/frontend/connect.lock
|
||||
/frontend/coverage
|
||||
/frontend/libpeerconnection.log
|
||||
/frontend/**/testem.log
|
||||
/frontend/typings
|
||||
|
||||
/frontend/**/.DS_Store
|
||||
/frontend/**/Thumbs.db
|
||||
frontend/**/.DS_Store
|
||||
frontend/**/Thumbs.db
|
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@ -8,7 +8,7 @@
|
||||
"name": "Launch Backend",
|
||||
"type": "pwa-node",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/src/index.ts",
|
||||
"program": "${workspaceFolder}/main.ts",
|
||||
"cwd": "${workspaceFolder}/cwd",
|
||||
"runtimeExecutable": "deno",
|
||||
"runtimeArgs": [
|
||||
|
31
README.md
31
README.md
@ -12,10 +12,37 @@ Created by TopchetoEU
|
||||
|
||||
This is exactly what the title sells it for - it's an imgur clone (but kinda worse).
|
||||
|
||||
## How to use?
|
||||
## Running the code
|
||||
|
||||
Currently, we only have a backend, which can be easily run via the command (in the main directory):
|
||||
### Development
|
||||
|
||||
Start the backend with:
|
||||
|
||||
```sh
|
||||
# Executed in the backend folder
|
||||
$ deno run -A src/index.ts
|
||||
```
|
||||
|
||||
And the frontend with:
|
||||
|
||||
```sh
|
||||
# Executed in the frontend folder
|
||||
$ ng serve
|
||||
```
|
||||
|
||||
### Production
|
||||
|
||||
First, build the frontend:
|
||||
|
||||
```sh
|
||||
# Executed in the frontend folder
|
||||
$ ng build
|
||||
```
|
||||
|
||||
Then, copy the contents of backend/static. Finally start the backend:
|
||||
|
||||
```sh
|
||||
# Executed in the backend folder
|
||||
$ deno run --allow-read --allow-write --allow-net main.ts
|
||||
```
|
||||
|
||||
|
@ -21,4 +21,3 @@ export default async function clonegur() {
|
||||
return new RootRouter(salt, new AppDatabase(db));
|
||||
}
|
||||
|
||||
(await clonegur()).attach(Deno.listen({ port: 4000, hostname: 'localhost' }));
|
5
backend/main.ts
Normal file
5
backend/main.ts
Normal file
@ -0,0 +1,5 @@
|
||||
import clonegur from "./clonegur.ts";
|
||||
|
||||
const app = await clonegur();
|
||||
const server = Deno.listen({ port: 4000, hostname: 'localhost' });
|
||||
app.attach(server);
|
@ -97,7 +97,7 @@ export default class Router {
|
||||
}
|
||||
}
|
||||
|
||||
public async attach(server: Deno.Listener) {
|
||||
public async attach(server: AsyncIterable<Deno.Conn>) {
|
||||
for await (const conn of server) {
|
||||
for await (const req of Deno.serveHttp(conn)) {
|
||||
const r = await this.handle(RestRequest.fromMessage(req));
|
19
backend/server/staticHandler.ts
Normal file
19
backend/server/staticHandler.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import RestResponse from "./RestResponse.ts";
|
||||
import { Handler } from "./Router.ts";
|
||||
|
||||
export default function staticHandler(path: string): Handler {
|
||||
return {
|
||||
async handle(req) {
|
||||
try {
|
||||
const stream = await Deno.open(`${req.url}/${path}`);
|
||||
const res: Uint8Array[] = [];
|
||||
for await (const bit of stream.readable) res.push(bit);
|
||||
stream.close();
|
||||
return new RestResponse().body(new Blob(res).stream());
|
||||
}
|
||||
catch {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user