forked from Chewing_Bever/rusty-bever
Tried to add MirageJS but failed
parent
6d83c18036
commit
548dd0d022
|
@ -1,5 +1,3 @@
|
||||||
//! Handles all posts-related database operations.
|
|
||||||
|
|
||||||
use chrono::NaiveDate;
|
use chrono::NaiveDate;
|
||||||
use diesel::{insert_into, prelude::*, Insertable, PgConnection, Queryable};
|
use diesel::{insert_into, prelude::*, Insertable, PgConnection, Queryable};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
@ -9,7 +7,6 @@ use crate::{
|
||||||
schema::{posts, posts::dsl::*},
|
schema::{posts, posts::dsl::*},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Represents a post contained within the database.
|
|
||||||
#[derive(Queryable)]
|
#[derive(Queryable)]
|
||||||
pub struct Post
|
pub struct Post
|
||||||
{
|
{
|
||||||
|
@ -20,7 +17,6 @@ pub struct Post
|
||||||
pub content: String,
|
pub content: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Represents a new post to be added to the database.
|
|
||||||
#[derive(Insertable)]
|
#[derive(Insertable)]
|
||||||
#[table_name = "posts"]
|
#[table_name = "posts"]
|
||||||
pub struct NewPost
|
pub struct NewPost
|
||||||
|
|
|
@ -23,7 +23,7 @@ pub struct Section
|
||||||
/// A new section to be added into the database.
|
/// A new section to be added into the database.
|
||||||
#[derive(Deserialize, Insertable)]
|
#[derive(Deserialize, Insertable)]
|
||||||
#[table_name = "sections"]
|
#[table_name = "sections"]
|
||||||
// #[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct NewSection
|
pub struct NewSection
|
||||||
{
|
{
|
||||||
title: String,
|
title: String,
|
||||||
|
|
|
@ -7,7 +7,9 @@
|
||||||
"build": "astro build"
|
"build": "astro build"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@astrojs/renderer-svelte": "^0.1.1",
|
||||||
"astro": "0.19.0-next.2",
|
"astro": "0.19.0-next.2",
|
||||||
"@astrojs/renderer-svelte": "^0.1.1"
|
"miragejs": "^0.1.41",
|
||||||
|
"typescript": "^4.4.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
<script lang="ts">
|
||||||
|
|
||||||
|
console.log("sup");
|
||||||
|
let movies = [];
|
||||||
|
|
||||||
|
fetch("/api/movies").then(res => res.json()).then(res => {
|
||||||
|
movies = res;
|
||||||
|
console.log(movies);
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
{#each movies as { id, name, year }, i}
|
||||||
|
<li><a target="_blank" href="https://www.youtube.com/watch?v={id}">
|
||||||
|
{i + 1}: {name} - {year}
|
||||||
|
</a></li>
|
||||||
|
{/each}
|
||||||
|
</ul>
|
|
@ -1,4 +1,4 @@
|
||||||
<script>
|
<script lang="ts">
|
||||||
let count = 0;
|
let count = 0;
|
||||||
|
|
||||||
function add() {
|
function add() {
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
|
---
|
||||||
|
---
|
||||||
|
|
||||||
<html>
|
<html>
|
||||||
<body>
|
<body>
|
||||||
<h1>huh</h1>
|
<h1>huh</h1>
|
||||||
<p>lol</p>
|
<p>lol</p>
|
||||||
|
<MirageTest />
|
||||||
<slot />
|
<slot />
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,3 +1,24 @@
|
||||||
|
---
|
||||||
|
import { createServer } from "miragejs"
|
||||||
|
import MirageTest from "../components/MirageTest"
|
||||||
|
|
||||||
|
createServer({
|
||||||
|
routes() {
|
||||||
|
this.namespace = "api"
|
||||||
|
|
||||||
|
this.get("/movies", () => {
|
||||||
|
return {
|
||||||
|
movies: [
|
||||||
|
{ id: 1, name: "Inception", year: 2010 },
|
||||||
|
{ id: 2, name: "Interstellar", year: 2014 },
|
||||||
|
{ id: 3, name: "Dunkirk", year: 2017 },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
})
|
||||||
|
---
|
||||||
|
|
||||||
<html>
|
<html>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
@ -7,6 +28,8 @@
|
||||||
<li class="nav-bar-item"><a href="/microblog">Microblog</a></li>
|
<li class="nav-bar-item"><a href="/microblog">Microblog</a></li>
|
||||||
<li class="nav-bar-item"><a href="/devlogs">Devlogs</a></li>
|
<li class="nav-bar-item"><a href="/devlogs">Devlogs</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
<MirageTest client:load />
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|
996
web/yarn.lock
996
web/yarn.lock
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue