Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blog-engine bad imports fixes and how to run instructions #506

Merged
merged 6 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion examples/blog-engine/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,32 @@
# README
# Blog Engine

## To run locally
1. Run `npm i` and then `npm run build:generator` in `elm-pages` root if you have not already.
2. Run `npm i` and then `npm run build` in this project directory.
3. This project requires a database and uses `prisma` to interact with it.
1. Have a Postgres database running. One way to do this is to have docker installed and run these command:
```bash
docker pull postgres
```
to download a docker image of postgres and then
```bash
docker run -d --name postgres-container -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432 postgres
```
to run a container with the image. This will start a postgres database on `localhost:5432` with the username `postgres` and password `postgres`.
2. Set the environment variable `BLOG_DATABASE_URL` to the connection string of the database e.g.
```bash
export BLOG_DATABASE_URL=postgresql://postgres:postgres@localhost/postgres
```
2. To set up the database tables configured in `prisma/schema.prisma`, run
```bash
npx prisma migrate dev --name init
```

2. To generate som example blog posts you can run
```bash
node prisma/seed.js
```
3. Start elm-pages dev with
```bash
npm run start
```
10 changes: 6 additions & 4 deletions examples/blog-engine/app/Route/Admin/Slug_.elm
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ module Route.Admin.Slug_ exposing (ActionData, Data, route, RouteParams, Msg, Mo

-}

import BackendTask
import BackendTask exposing (BackendTask)
import BackendTask.Custom
import Date exposing (Date)
import Effect
import ErrorPage
import FatalError
import Elm exposing (expose)
import ErrorPage exposing (ErrorPage)
import FatalError exposing (FatalError)
import Form exposing (Validated(..))
import Form.Field
import Form.FieldView
Expand All @@ -22,6 +23,7 @@ import Html exposing (Html)
import Html.Attributes
import Json.Decode as Decode exposing (Decoder)
import Json.Encode as Encode
import PageServerResponse exposing (PageServerResponse)
import Pages.Form
import PagesMsg exposing (PagesMsg)
import Platform.Sub
Expand Down Expand Up @@ -100,7 +102,7 @@ type alias ActionData =
data :
RouteParams
-> Request
-> BackendTask FatalError (ServeResponse Data ErrorPage)
-> BackendTask FatalError (PageServerResponse Data ErrorPage)
data routeParams request =
if routeParams.slug == "new" then
Server.Response.render
Expand Down
2 changes: 1 addition & 1 deletion examples/blog-engine/custom-backend-task.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PrismaClient } from "@prisma/client";
import { PrismaClientKnownRequestError } from "@prisma/client/runtime/index.js";
import { PrismaClientKnownRequestError } from "@prisma/client/runtime/library";

const prisma = new PrismaClient();

Expand Down
6 changes: 3 additions & 3 deletions examples/blog-engine/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 0 additions & 60 deletions examples/blog-engine/src/BasicAuth.elm

This file was deleted.

Loading