Compare commits

..

2 Commits
dev ... master

5 changed files with 26 additions and 44 deletions

View File

@ -1,19 +0,0 @@
pipeline:
install:
image: 'node:17.3.0'
commands:
- yarn install
# This step makes sure the project properly builds.
build:
image: 'node:17.3.0'
group: test
commands:
- yarn run build
lint:
image: 'node:17.3.0'
group: test
commands:
- yarn run lint

View File

@ -1,15 +1,15 @@
const API_PREFIX = '/api/v1' const API_PREFIX = "/api/v1"
export class RbApi { export class RbApi {
async get_json(path) { async get_json(path) {
const url = `${API_PREFIX}${path}` const url = `${API_PREFIX}${path}`
const res = await fetch(url) let res = await fetch(url)
return await res.json() return await res.json()
} }
async sections() { async sections() {
const res = await this.get_json('/sections') let res = await this.get_json("/sections")
return res.sections return res["sections"]
} }
} }

View File

@ -3,9 +3,9 @@ import { ref } from 'vue'
import { RbApi } from '../api/v1' import { RbApi } from '../api/v1'
import { Section } from '../models' import { Section } from '../models'
const sections = ref([]) let sections = ref([])
const api = new RbApi() let api = new RbApi()
await api.sections().then(res => { await api.sections().then(res => {
sections.value = res sections.value = res
}) })
@ -16,7 +16,7 @@ await api.sections().then(res => {
<div> <div>
<p>yeet</p> <p>yeet</p>
<ul> <ul>
<li v-for="section in sections"> <li v-for='section in sections'>
{{ section }} {{ section }}
</li> </li>
</ul> </ul>

View File

@ -29,21 +29,21 @@ export const sections = [
is_private: false, is_private: false,
is_archived: false is_archived: false
} }
] ];
export const posts = [ export const posts = [
{ {
id: 'af08bbcd-f6eb-446e-b355-13e0a0ef008e', id: 'af08bbcd-f6eb-446e-b355-13e0a0ef008e',
section_id: sections[0].id, section_id: sections[0]['id'],
is_private: false, is_private: false,
is_archived: false is_archived: false
} }
] ];
export const versions = [ export const versions = [
{ {
id: '8c5bc2f9-e52f-4e19-bd76-119cc42ff863', id: '8c5bc2f9-e52f-4e19-bd76-119cc42ff863',
post_id: posts[0].id, post_id: posts[0]['id'],
title: 'This Is A Title', title: 'This Is A Title',
publish_date: '2021-12-28', publish_date: '2021-12-28',
content: 'Hello. This is some content!', content: 'Hello. This is some content!',

View File

@ -1,5 +1,5 @@
import { createServer, Model } from 'miragejs' import { createServer, Model } from 'miragejs';
import { sections, posts, versions } from './models' import { sections, posts, versions } from './models';
export function makeServer ({ environment = 'development' } = {}) { export function makeServer ({ environment = 'development' } = {}) {
const server = createServer({ const server = createServer({
@ -12,26 +12,27 @@ export function makeServer ({ environment = 'development' } = {}) {
}, },
seeds (server) { seeds (server) {
sections.forEach(s => server.create('section', s)) sections.forEach(s => server.create('section', s));
posts.forEach(s => server.create('post', s)) posts.forEach(s => server.create('post', s));
versions.forEach(s => server.create('version', s)) versions.forEach(s => server.create('version', s));
}, },
routes () { routes () {
this.namespace = 'api/v1' this.namespace = 'api/v1';
// Offsets & limits don't need to be implemented here, as the data set isn't large enough to require this yet // Offsets & limits don't need to be implemented here, as the data set isn't large enough to require this yet
this.get('/sections', (schema) => { this.get('/sections', (schema) => {
return schema.sections.all() return schema.sections.all();
}) })
this.get('/posts', (schema) => { this.get('/posts', (schema) => {
return schema.posts.all() return schema.posts.all();
}) })
this.get('/versions', (schema) => { this.get('/versions', (schema) => {
return schema.versions.all() return schema.versions.all();
}) })
} }
}) });
return server return server;
} }