running prettier across the app
This commit is contained in:
10
.vscode/settings.json
vendored
10
.vscode/settings.json
vendored
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"editor.codeActionsOnSave": {
|
"editor.codeActionsOnSave": {
|
||||||
"source.fixAll": "explicit",
|
"source.fixAll": "explicit",
|
||||||
"source.organizeImports": "explicit",
|
"source.organizeImports": "explicit",
|
||||||
"source.sortMembers": "explicit"
|
"source.sortMembers": "explicit"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
79
api/app.js
79
api/app.js
@@ -1,55 +1,54 @@
|
|||||||
|
import cookieParser from 'cookie-parser'
|
||||||
|
import cors from 'cors'
|
||||||
|
import express from 'express'
|
||||||
|
import createError from 'http-errors'
|
||||||
|
import logger from 'morgan'
|
||||||
|
import path from 'path'
|
||||||
|
import { fileURLToPath } from 'url'
|
||||||
|
import xss from 'xss-clean'
|
||||||
|
|
||||||
import cookieParser from 'cookie-parser';
|
import indexRouter from './routes/index.js'
|
||||||
import cors from 'cors';
|
import postsRouter from './routes/posts.js'
|
||||||
import express from 'express';
|
import usersRouter from './routes/users.js'
|
||||||
import createError from 'http-errors';
|
|
||||||
import logger from 'morgan';
|
|
||||||
import path from 'path';
|
|
||||||
import { fileURLToPath } from 'url';
|
|
||||||
import xss from 'xss-clean';
|
|
||||||
|
|
||||||
import indexRouter from './routes/index.js';
|
const __filename = fileURLToPath(import.meta.url)
|
||||||
import postsRouter from './routes/posts.js';
|
const __dirname = path.dirname(__filename)
|
||||||
import usersRouter from './routes/users.js';
|
|
||||||
|
|
||||||
const __filename = fileURLToPath(import.meta.url);
|
const app = express()
|
||||||
const __dirname = path.dirname(__filename);
|
|
||||||
|
|
||||||
const app = express();
|
|
||||||
|
|
||||||
// view engine setup
|
// view engine setup
|
||||||
app.set('views', path.join(__dirname, 'views'));
|
app.set('views', path.join(__dirname, 'views'))
|
||||||
app.set('view engine', 'jade');
|
app.set('view engine', 'jade')
|
||||||
|
|
||||||
app.use(cors());
|
app.use(cors())
|
||||||
app.options('*', cors());
|
app.options('*', cors())
|
||||||
|
|
||||||
app.use(logger('dev'));
|
app.use(logger('dev'))
|
||||||
app.use(express.json());
|
app.use(express.json())
|
||||||
app.use(express.urlencoded({ extended: false }));
|
app.use(express.urlencoded({ extended: false }))
|
||||||
app.use(cookieParser());
|
app.use(cookieParser())
|
||||||
app.use(express.static(path.join(__dirname, 'public')));
|
app.use(express.static(path.join(__dirname, 'public')))
|
||||||
// Data sanitization against XSS
|
// Data sanitization against XSS
|
||||||
app.use(xss());
|
app.use(xss())
|
||||||
|
|
||||||
app.use('/', indexRouter);
|
app.use('/', indexRouter)
|
||||||
app.use('/api/v1/users', usersRouter);
|
app.use('/api/v1/users', usersRouter)
|
||||||
app.use('/api/v1/posts', postsRouter);
|
app.use('/api/v1/posts', postsRouter)
|
||||||
|
|
||||||
// catch 404 and forward to error handler
|
// catch 404 and forward to error handler
|
||||||
app.use(function(req, res, next) {
|
app.use(function (req, res, next) {
|
||||||
next(createError(404));
|
next(createError(404))
|
||||||
});
|
})
|
||||||
|
|
||||||
// error handler
|
// error handler
|
||||||
app.use(function(err, req, res, next) {
|
app.use(function (err, req, res, next) {
|
||||||
// set locals, only providing error in development
|
// set locals, only providing error in development
|
||||||
res.locals.message = err.message;
|
res.locals.message = err.message
|
||||||
res.locals.error = req.app.get('env') === 'development' ? err : {};
|
res.locals.error = req.app.get('env') === 'development' ? err : {}
|
||||||
|
|
||||||
// render the error page
|
// render the error page
|
||||||
res.status(err.status || 500);
|
res.status(err.status || 500)
|
||||||
res.render('error');
|
res.render('error')
|
||||||
});
|
})
|
||||||
|
|
||||||
export default app;
|
export default app
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import User from '../models/userModel.js';
|
import User from '../models/userModel.js'
|
||||||
|
|
||||||
export const getAllUsers = async (req, res, next) => {
|
export const getAllUsers = async (req, res, next) => {
|
||||||
const allUsers = await User.find({}).exec();
|
const allUsers = await User.find({}).exec()
|
||||||
res.status(200).json({
|
res.status(200).json({
|
||||||
status: 'success',
|
status: 'success',
|
||||||
data: allUsers
|
data: allUsers
|
||||||
@@ -9,39 +9,39 @@ export const getAllUsers = async (req, res, next) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const getUser = async (req, res, next) => {
|
export const getUser = async (req, res, next) => {
|
||||||
const user = await User.findById(req.params.id).exec();
|
const user = await User.findById(req.params.id).exec()
|
||||||
if (!user) {
|
if (!user) {
|
||||||
return next('No document found with that id', 404);
|
return next('No document found with that id', 404)
|
||||||
}
|
}
|
||||||
res.status(200).json({
|
res.status(200).json({
|
||||||
status: 'success',
|
status: 'success',
|
||||||
data: user
|
data: user
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const createUser = async (req, res, next) => {
|
export const createUser = async (req, res, next) => {
|
||||||
User.create(req.body).then(result => {
|
User.create(req.body).then((result) => {
|
||||||
res.status(200).json({
|
res.status(200).json({
|
||||||
status: 'success',
|
status: 'success',
|
||||||
data: result
|
data: result
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const updateUser = async (req, res, next) => {
|
export const updateUser = async (req, res, next) => {
|
||||||
User.updateOne({_id: req.params.id},{$set: req.body}).then(result => {
|
User.updateOne({ _id: req.params.id }, { $set: req.body }).then((result) => {
|
||||||
res.status(200).json({
|
res.status(200).json({
|
||||||
status: 'success',
|
status: 'success',
|
||||||
data: result
|
data: result
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const deleteUser = async (req, res, next) => {
|
export const deleteUser = async (req, res, next) => {
|
||||||
User.deleteOne({_id: req.params.id}).then(result => {
|
User.deleteOne({ _id: req.params.id }).then((result) => {
|
||||||
res.status(200).json({
|
res.status(200).json({
|
||||||
status: 'success',
|
status: 'success',
|
||||||
data: result
|
data: result
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
|
import express from 'express'
|
||||||
import express from 'express';
|
const router = express.Router()
|
||||||
const router = express.Router();
|
|
||||||
|
|
||||||
/* GET home page. */
|
/* GET home page. */
|
||||||
router.get('/', function(req, res, next) {
|
router.get('/', function (req, res, next) {
|
||||||
res.send('index');
|
res.send('index')
|
||||||
});
|
})
|
||||||
|
|
||||||
export default router;
|
export default router
|
||||||
|
|||||||
@@ -1,17 +1,9 @@
|
|||||||
|
import express from 'express'
|
||||||
|
import { createUser, deleteUser, getAllUsers, getUser, updateUser } from './../controllers/usersController.js'
|
||||||
|
const router = express.Router()
|
||||||
|
|
||||||
import express from 'express';
|
router.route('/').get(getAllUsers).post(createUser)
|
||||||
import { createUser, deleteUser, getAllUsers, getUser, updateUser } from './../controllers/usersController.js';
|
|
||||||
const router = express.Router();
|
|
||||||
|
|
||||||
router
|
router.route('/:id').get(getUser).patch(updateUser).delete(deleteUser)
|
||||||
.route('/')
|
|
||||||
.get(getAllUsers)
|
|
||||||
.post(createUser);
|
|
||||||
|
|
||||||
router
|
export default router
|
||||||
.route('/:id')
|
|
||||||
.get(getUser)
|
|
||||||
.patch(updateUser)
|
|
||||||
.delete(deleteUser);
|
|
||||||
|
|
||||||
export default router;
|
|
||||||
|
|||||||
@@ -1,30 +1,30 @@
|
|||||||
import { Link, Stack } from 'expo-router';
|
import { Link, Stack } from 'expo-router'
|
||||||
import { StyleSheet, View } from 'react-native';
|
import { StyleSheet, View } from 'react-native'
|
||||||
|
|
||||||
export default function NotFoundScreen() {
|
export default function NotFoundScreen() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Stack.Screen options={{ headerShown: false }} />
|
<Stack.Screen options={{ headerShown: false }} />
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
<Link href="./" style={styles.button}>
|
<Link href='./' style={styles.button}>
|
||||||
Go back to Home screen!
|
Go back to Home screen!
|
||||||
</Link>
|
</Link>
|
||||||
</View>
|
</View>
|
||||||
</>
|
</>
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
backgroundColor: '#25292e',
|
backgroundColor: '#25292e',
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
alignItems: 'center',
|
alignItems: 'center'
|
||||||
},
|
},
|
||||||
|
|
||||||
button: {
|
button: {
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
textDecorationLine: 'underline',
|
textDecorationLine: 'underline',
|
||||||
color: '#fff',
|
color: '#fff'
|
||||||
},
|
}
|
||||||
});
|
})
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
// https://docs.expo.dev/guides/using-eslint/
|
// https://docs.expo.dev/guides/using-eslint/
|
||||||
const { defineConfig } = require('eslint/config');
|
const { defineConfig } = require('eslint/config')
|
||||||
const expoConfig = require('eslint-config-expo/flat');
|
const expoConfig = require('eslint-config-expo/flat')
|
||||||
|
|
||||||
module.exports = defineConfig([
|
module.exports = defineConfig([
|
||||||
expoConfig,
|
expoConfig,
|
||||||
{
|
{
|
||||||
ignores: ['dist/*'],
|
ignores: ['dist/*']
|
||||||
},
|
}
|
||||||
]);
|
])
|
||||||
|
|||||||
27940
package-lock.json
generated
27940
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,17 +1,10 @@
|
|||||||
{
|
{
|
||||||
"extends": "expo/tsconfig.base",
|
"extends": "expo/tsconfig.base",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"paths": {
|
"paths": {
|
||||||
"@/*": [
|
"@/*": ["./*"]
|
||||||
"./*"
|
}
|
||||||
]
|
},
|
||||||
}
|
"include": ["**/*.ts", "**/*.tsx", ".expo/types/**/*.ts", "expo-env.d.ts"]
|
||||||
},
|
|
||||||
"include": [
|
|
||||||
"**/*.ts",
|
|
||||||
"**/*.tsx",
|
|
||||||
".expo/types/**/*.ts",
|
|
||||||
"expo-env.d.ts"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user