Skip to content

Commit

Permalink
update http status message
Browse files Browse the repository at this point in the history
  • Loading branch information
tysonrm committed Nov 19, 2022
1 parent 7abe6ad commit 0828694
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/adapters/controllers/delete-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default function deleteModelFactory (removeModel) {
} catch (e) {
console.error(e)

if (e.message === 'no such id') {
if (e.message === 'Not Found') {
return {
headers: {
'Content-Type': 'application/json'
Expand Down
4 changes: 2 additions & 2 deletions src/adapters/controllers/get-model-by-id.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default function getModelByIdFactory (findModel) {
try {
httpRequest.log(getModelById.name)

const model = await findModel({
const model = await findModel({
id: httpRequest.params.id,
query: httpRequest.query
})
Expand All @@ -30,7 +30,7 @@ export default function getModelByIdFactory (findModel) {
} catch (e) {
console.error(e.message)

if (e.message === 'no such id') {
if (e.message === 'Not Found') {
return {
headers: {
'Content-Type': 'application/json'
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/controllers/patch-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default function patchModelFactory (editModel) {
} catch (e) {
console.error(e)

if (e.message === 'no such id') {
if (e.message === 'Not Found') {
return {
headers: {
'Content-Type': 'application/json'
Expand Down
2 changes: 1 addition & 1 deletion src/domain/use-cases/edit-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default function makeEditModel ({
if (isMainThread) {
const model = await repository.find(input.id)

if (!model) throw new Error('no such id')
if (!model) throw new Error('Not Found')

return threadpool.runJob(editModel.name, input, modelName)
} else {
Expand Down
14 changes: 8 additions & 6 deletions src/domain/use-cases/find-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,20 @@ export default function makeFindModel ({
const model = await repository.find(id)

if (!model) {
throw new Error('no such id')
throw new Error('Not Found')
}

console.log({ fn: findModel.name, model })
// Only send to app thread if data must be enriched
if (!query.relation && !query.command) return model

return await threadpool.runJob(findModel.name, {
id,
query,
model
},
return await threadpool.runJob(
findModel.name,
{
id,
query,
model
},
modelName
)
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/domain/use-cases/remove-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default function removeModelFactory ({
return async function removeModel ({ id }) {
if (isMainThread) {
const model = await repository.find(id)
if (!model) throw new Error('no such id')
if (!model) throw new Error('Not Found')

return threadpool.runJob(removeModel.name, { id }, modelName)
} else {
Expand Down
13 changes: 6 additions & 7 deletions start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
#export FORKRUN_CMD=/Users/tysonmidboe/.nvm/versions/node/v18.12.0/bin/node
#export FORKRUN_ARG=/Users/tysonmidboe/aegis-app/repo.jsjjj

nvm install --lts
nvm use --lts
# nvm install --lts
# nvm use --lts

export FORKRUN_CMD=$NVM_BIN/node
export FORKRUN_ARG=$PWD/repo.js
# export FORKRUN_CMD=$NVM_BIN/node
# export FORKRUN_ARG=$PWD/repo.js

gcc forkrun.c -o forkrun
./forkrun
# gcc forkrun.c -o forkrun
# ./forkrun
yarn link
cd ../aegis-host
yarn build
yarn link @module-federation/aegis
yarn start

0 comments on commit 0828694

Please sign in to comment.