-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
965 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,5 @@ yarn-error.log | |
web/public/mockServiceWorker.js | ||
web/types/graphql.d.ts | ||
api/types/graphql.d.ts | ||
|
||
fs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import fs from 'fs' | ||
|
||
export async function listDir(path: string): Promise<Array<string>> { | ||
return new Promise((resolve, reject) => { | ||
fs.readdir(path, (err, files) => { | ||
if(err) { | ||
reject(err) | ||
} else { | ||
resolve(files) | ||
} | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import {Server} from 'node-static'; | ||
|
||
export function staticServer(path: string) { | ||
const file = new Server(path); | ||
const port = 8080; | ||
|
||
require('http').createServer(function (request, response) { | ||
request.addListener('end', function () { | ||
file.serve(request, response); | ||
}).resume(); | ||
}).listen(port); | ||
|
||
console.log(`Static server started, path ${path}, port ${port}`) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import type { Prisma } from '@prisma/client' | ||
|
||
import { listDir } from "api/src/lib/files"; | ||
import { db } from 'api/src/lib/db' | ||
|
||
export default async () => { | ||
|
||
const path = process.env["FILESYSTEM_FOLDER"] | ||
const files = await listDir(path) | ||
console.log("importing files", files) | ||
Promise.all( | ||
// | ||
// Change to match your data model and seeding needs | ||
// | ||
files.map(async (path: Prisma.ImageCreateInput['path']) => { | ||
const record = await db.image.create({ data: { path } }) | ||
console.log(record) | ||
}) | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { staticServer } from "api/src/lib/static"; | ||
|
||
export default async () => { | ||
const path = process.env["FILESYSTEM_FOLDER"] | ||
staticServer(path) | ||
} |
Oops, something went wrong.