Skip to content

Commit

Permalink
Add sample data to the INN server
Browse files Browse the repository at this point in the history
  • Loading branch information
cclauss committed Nov 1, 2024
1 parent 8fc21d2 commit 02886a0
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 51 deletions.
56 changes: 6 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,61 +23,17 @@ sequenceDiagram
FE2-on-NodeServer->>Browser: API Data response
```

## Install the components:
### [InterNetNews](https://github.com/InterNetNews/inn) will be run in a Docker container:
Also:
* <https://www.isc.org/othersoftware/#INN>
* <https://www.eyrie.org/~eagle/software/inn/docs-2.7>
* <https://github.com/cclauss/apt-get-inn2-docker>

### [FastAPI](https://fastapi.tiangolo.com/)-Server will be run in a Docker container:
From the project root directory

### NodeServer (Node.js Vue app)
From the project root directory
```bash
cd fe
npm install
```

## Run the components
For local development and testing, start the INN2 server and FastAPI server with:
```bash
docker compose -f docker-compose.debug.yml up
```

### InterNetNews server:
For local development and testing, start the INN2 server with:
```bash
docker run --rm -t -p119:119 -p563:563 cclauss/inn
```

### FastAPI Python app:
For local development and testing:
```bash
pipenv shell
PYTHONPATH=. fastapi dev --host=0.0.0.0 --port=5001 server/main.py

open http://localhost:5001
open http://localhost:5001/docs
```

Or docker build and run the FastAPI server in background mode and
follow the logs with:
```bash
docker build --tag=fastapi-server --no-cache --progress=plain . \
&& docker run --detach --publish=5001:5001 fastapi-server \
&& docker logs -f $(docker ps -lq)

open http://localhost:5001
open http://localhost:5001/docs
```

### FE NodeServer
```bash
cd fe
npm run dev --host=0.0.0.0
```
* [InterNetNews](https://github.com/InterNetNews/inn) (INN) backend that houses the metadata.
* <https://www.isc.org/othersoftware/#INN>
* <https://www.eyrie.org/~eagle/software/inn/docs-2.7>
* <https://github.com/cclauss/apt-get-inn2-docker>
* [FastAPI](https://fastapi.tiangolo.com/)-Server middle tier that connects the INN to the frontend.
* [FE2](./FE2/README.md) user interface that connects to the FastAPI-Server.

### FE2 NodeServer
```bash
Expand Down
9 changes: 9 additions & 0 deletions fe2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ should probably be a Node.js server process that can handle 4xx and 5xx
errors. After we have communication running from FE2 to Server to INN2,
we can reevaluate where further code changes should be focused.

```bash
cd fe2
npm ci
npm run start
# Wait for `webpack x.y.z compiled successfully`
open http://localhost:4000/imls
```


## % `cd fe2 && npm run`

```
Expand Down
19 changes: 18 additions & 1 deletion server/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
# FastAPI server
## A backend for the FE2 user interface

Build and run the FastAPI server in background mode and follow the logs.
### Using Docker

Docker build and run the FastAPI server in background mode and
follow the logs with:
```bash
docker build --tag=fastapi-server --no-cache --progress=plain . \
&& docker run --detach --publish=5001:5001 fastapi-server \
&& docker logs -f $(docker ps -lq)

open http://localhost:5001
open http://localhost:5001/docs
```
Options:
* Remove `--no-cache` to accelerate rebuilds.
Expand All @@ -18,3 +24,14 @@ To kill the background container, run:
```bash
docker kill $(docker ps -lq)
```

### Without Docker

For local development and testing:
```bash
pipenv shell
PYTHONPATH=. fastapi dev --host=0.0.0.0 --port=5001 server/main.py

open http://localhost:5001
open http://localhost:5001/docs
```
6 changes: 6 additions & 0 deletions server/main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os

from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from fastapi.staticfiles import StaticFiles
Expand All @@ -16,6 +18,10 @@
allow_headers=["*"],
)

# If we are not running in Continuous Integration then enable the INN local.test group.
if not os.getenv("CI"): # Not running in Continuous Integration
ome_node.DEFAULT_NEWSGROUPS.remove(("local.test", "Local test group"))


@app.get("/api/list")
async def main() -> list[Channel]:
Expand Down

0 comments on commit 02886a0

Please sign in to comment.