diff --git a/README.md b/README.md
index f6347d43..0f74f6ad 100644
--- a/README.md
+++ b/README.md
@@ -24,18 +24,11 @@ The flow of the application you build looks like this:
Take a little bit of time to familiarise yourself with the project structure - this exercise has both a front-end React
app (`src/client/`) *and* a back-end express API (`src/server/`) in it.
-1. Fork this repository and clone the fork.
- 1. If you want to use the more challenging `freedom` branch, remember to UNCHECK the checkbox for "Copy the
- `main` branch only"
-
-
- 2. Then, once you have cloned your fork of the repo, you can run `git checkout freedom` in your terminal.
- 3. If you do not uncheck this box, then you will only be able to access the `main` branch.
-2. Rename `.env.example` to `.env`
-3. Edit the `DATABASE_URL` variable in `.env`, swapping `YOUR_DATABASE_URL` for the URL of your database
-4. Run `npm ci` to install the project dependencies.
-5. If you're using the main branch, we have already created the Prisma schema and migrations for you. Run `npx prisma migrate reset` to execute the
- database migrations. Press `y` when it asks if you're sure.
+**Note:** Since you are using the freedom branch, all we've done is add the require dependencies and place (almost) empty index files into the src/ sub-directories. Everything else is up to you.
+
+1. Rename `.env.example` to `.env`
+2. Edit the `DATABASE_URL` variable in `.env`, swapping `YOUR_DATABASE_URL` for the URL of your database
+3. Run `npm ci` to install the project dependencies.
## Instructions
diff --git a/index.html b/index.html
index 0c589ecc..0ccc3959 100644
--- a/index.html
+++ b/index.html
@@ -4,7 +4,7 @@
-
Vite + React
+ Auth Challenge
diff --git a/prisma/migrations/20220211144514_init/migration.sql b/prisma/migrations/20220211144514_init/migration.sql
deleted file mode 100644
index d20c1f64..00000000
--- a/prisma/migrations/20220211144514_init/migration.sql
+++ /dev/null
@@ -1,28 +0,0 @@
--- CreateTable
-CREATE TABLE "User" (
- "id" SERIAL NOT NULL,
- "username" TEXT NOT NULL,
- "password" TEXT NOT NULL,
- "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "updatedAt" TIMESTAMP(3) NOT NULL,
-
- CONSTRAINT "User_pkey" PRIMARY KEY ("id")
-);
-
--- CreateTable
-CREATE TABLE "Movie" (
- "id" SERIAL NOT NULL,
- "title" TEXT NOT NULL,
- "description" TEXT NOT NULL,
- "runtimeMins" INTEGER NOT NULL,
- "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "updatedAt" TIMESTAMP(3) NOT NULL,
-
- CONSTRAINT "Movie_pkey" PRIMARY KEY ("id")
-);
-
--- CreateIndex
-CREATE UNIQUE INDEX "User_username_key" ON "User"("username");
-
--- CreateIndex
-CREATE UNIQUE INDEX "Movie_title_key" ON "Movie"("title");
diff --git a/prisma/migrations/migration_lock.toml b/prisma/migrations/migration_lock.toml
deleted file mode 100644
index 6bf90154..00000000
--- a/prisma/migrations/migration_lock.toml
+++ /dev/null
@@ -1,3 +0,0 @@
-# Please do not edit this file manually
-# It should be added in your version-control system (i.e. Git)
-provider = "postgresql"
\ No newline at end of file
diff --git a/prisma/schema.prisma b/prisma/schema.prisma
deleted file mode 100644
index 68676dd3..00000000
--- a/prisma/schema.prisma
+++ /dev/null
@@ -1,29 +0,0 @@
-// This is your Prisma schema file,
-// learn more about it in the docs: https://pris.ly/d/prisma-schema
-
-generator client {
- provider = "prisma-client-js"
-}
-
-datasource db {
- provider = "postgresql"
- url = env("DATABASE_URL")
- shadowDatabaseUrl = env("SHADOW_DATABASE_URL")
-}
-
-model User {
- id Int @id @default(autoincrement())
- username String @unique
- password String
- createdAt DateTime @default(now())
- updatedAt DateTime @updatedAt
-}
-
-model Movie {
- id Int @id @default(autoincrement())
- title String @unique
- description String
- runtimeMins Int
- createdAt DateTime @default(now())
- updatedAt DateTime @updatedAt
-}
diff --git a/src/client/App.jsx b/src/client/App.jsx
index bae3b635..f5e08f1b 100644
--- a/src/client/App.jsx
+++ b/src/client/App.jsx
@@ -1,75 +1,10 @@
-import { useEffect, useState } from 'react';
import './App.css';
-import MovieForm from './components/MovieForm';
-import UserForm from './components/UserForm';
const port = import.meta.env.VITE_PORT;
const apiUrl = `http://localhost:${port}`;
function App() {
- const [movies, setMovies] = useState([]);
-
- useEffect(() => {
- fetch(`${apiUrl}/movie`)
- .then(res => res.json())
- .then(res => setMovies(res.data));
- }, []);
-
- /**
- * HINTS!
- * 1. This handle___ functions below use async/await to handle promises, but the
- * useEffect above is using .then to handle them. Both are valid approaches, but
- * we should ideally use one or the other. Pick whichever you prefer.
- *
- * 2. The default method for the `fetch` API is to make a GET request. To make other
- * types of requests, we must provide an object as the second argument of `fetch`.
- * The values that you must provide are:
- * - method
- * - headers
- * - body (if needed)
- * For the "headers" property, you must state the content type of the body, i.e.:
- * headers: {
- * 'Content-Type': 'application/json'
- * }
- * */
-
- const handleRegister = async ({ username, password }) => {
-
- };
-
- const handleLogin = async ({ username, password }) => {
-
- };
-
- const handleCreateMovie = async ({ title, description, runtimeMins }) => {
-
- }
-
- return (
-
-
Register
-
-
-
Login
-
-
-
Create a movie
-
-
-
Movie list
-
- {movies.map(movie => {
- return (
-
-
{movie.title}
-
Description: {movie.description}
-
Runtime: {movie.runtimeMins}
-
- );
- })}
-
-
- );
+ return <>>;
}
export default App;
diff --git a/src/client/components/MovieForm.jsx b/src/client/components/MovieForm.jsx
deleted file mode 100644
index a3d92402..00000000
--- a/src/client/components/MovieForm.jsx
+++ /dev/null
@@ -1,28 +0,0 @@
-import { useState } from "react";
-
-export default function MovieForm({ handleSubmit }) {
- const [movie, setMovie] = useState({ title: '', description: '', runtimeMins: 60 });
-
- const handleSubmitDecorator = (e) => {
- e.preventDefault();
- handleSubmit(movie);
- }
-
- const handleChange = (e) => {
- const { name, value } = e.target;
-
- setMovie({
- ...movie,
- [name]: name === 'runtimeMins' ? parseInt(value) : value
- });
- }
-
- return (
-
- );
-}
\ No newline at end of file
diff --git a/src/client/components/UserForm.jsx b/src/client/components/UserForm.jsx
deleted file mode 100644
index 328f90b4..00000000
--- a/src/client/components/UserForm.jsx
+++ /dev/null
@@ -1,27 +0,0 @@
-import { useState } from "react";
-
-export default function UserForm({ handleSubmit }) {
- const [user, setUser] = useState({ username: '', password: '' });
-
- const handleSubmitDecorator = (e) => {
- e.preventDefault();
- handleSubmit(user);
- };
-
- const handleChange = (e) => {
- const { name, value } = e.target;
-
- setUser({
- ...user,
- [name]: value
- });
- };
-
- return (
-
- );
-}
\ No newline at end of file
diff --git a/src/server/controllers/movie.js b/src/server/controllers/movie.js
deleted file mode 100644
index d4733b61..00000000
--- a/src/server/controllers/movie.js
+++ /dev/null
@@ -1,31 +0,0 @@
-import jwt from 'jsonwebtoken';
-import { PrismaClient } from '@prisma/client'
-const prisma = new PrismaClient();
-
-const jwtSecret = 'mysecret';
-
-const getAllMovies = async (req, res) => {
- const movies = await prisma.movie.findMany();
-
- res.json({ data: movies });
-};
-
-const createMovie = async (req, res) => {
- const { title, description, runtimeMins } = req.body;
-
- try {
- const token = null;
- // todo verify the token
- } catch (e) {
- return res.status(401).json({ error: 'Invalid token provided.' })
- }
-
- const createdMovie = null;
-
- res.json({ data: createdMovie });
-};
-
-export {
- getAllMovies,
- createMovie
-};
diff --git a/src/server/controllers/user.js b/src/server/controllers/user.js
deleted file mode 100644
index 05db4183..00000000
--- a/src/server/controllers/user.js
+++ /dev/null
@@ -1,39 +0,0 @@
-import bcrypt from 'bcrypt';
-import jwt from 'jsonwebtoken';
-import { PrismaClient } from '@prisma/client'
-const prisma = new PrismaClient();
-
-const jwtSecret = 'mysecret';
-
-const register = async (req, res) => {
- const { username, password } = req.body;
-
- const createdUser = null;
-
- res.json({ data: createdUser });
-};
-
-const login = async (req, res) => {
- const { username, password } = req.body;
-
- const foundUser = null;
-
- if (!foundUser) {
- return res.status(401).json({ error: 'Invalid username or password.' });
- }
-
- const passwordsMatch = false;
-
- if (!passwordsMatch) {
- return res.status(401).json({ error: 'Invalid username or password.' });
- }
-
- const token = null;
-
- res.json({ data: token });
-};
-
-export {
- register,
- login
-};
diff --git a/src/server/index.js b/src/server/index.js
index 1edd415d..acbd9268 100644
--- a/src/server/index.js
+++ b/src/server/index.js
@@ -2,36 +2,7 @@
import { config } from 'dotenv';
config();
-// Import express and cors
-import express from 'express';
-import cors from 'cors';
-// Set up express
-const app = express();
-app.disable('x-powered-by');
-app.use(cors());
-// Tell express to use a JSON parser middleware
-app.use(express.json());
-// Tell express to use a URL Encoding middleware
-app.use(express.urlencoded({ extended: true }));
-
-
-
-
-import userRouter from './routers/user.js';
-app.use('/user', userRouter);
-
-import movieRouter from './routers/movie.js';
-app.use('/movie', movieRouter);
-
-
-
-
-// Set up a default "catch all" route to use when someone visits a route
-// that we haven't built
-app.get('*', (req, res) => {
- res.json({ ok: true });
-});
// Start our API server
const port = process.env.VITE_PORT;
diff --git a/src/server/routers/movie.js b/src/server/routers/movie.js
deleted file mode 100644
index a606c4c9..00000000
--- a/src/server/routers/movie.js
+++ /dev/null
@@ -1,9 +0,0 @@
-import express from 'express';
-import { getAllMovies, createMovie } from '../controllers/movie.js';
-
-const router = express.Router();
-
-router.get('/', getAllMovies);
-router.post('/', createMovie);
-
-export default router;
diff --git a/src/server/routers/user.js b/src/server/routers/user.js
deleted file mode 100644
index 086a7f7b..00000000
--- a/src/server/routers/user.js
+++ /dev/null
@@ -1,9 +0,0 @@
-import express from 'express';
-import { register, login } from '../controllers/user.js';
-
-const router = express.Router();
-
-router.post('/register', register);
-router.post('/login', login);
-
-export default router;