nitro-web 0.0.29 → 0.0.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,54 +2,54 @@
2
2
  import db from 'monastery'
3
3
 
4
4
  export default {
5
-
6
5
  routes: {
7
6
  'put /api/company/:cid': ['isCompanyUser', 'update'],
8
7
  'put /api/user/:uid': ['isUser', 'updateUser'],
9
8
  },
9
+ update: update,
10
+ updateUser: updateUser,
11
+ }
10
12
 
11
- update: async function(req, res) {
12
- try {
13
- const update = await db.company.update({
14
- query: req.params.cid,
15
- data: req.body,
16
- files: req.query.files ? req.files : undefined,
17
- })
18
- if (!update) {
19
- throw new Error('Coudln\'t find the company to update')
20
- }
21
- const company = await db.company.findOne({
22
- query: req.params.cid,
23
- populate: db.company.loginPopulate(),
24
- _privateData: true,
25
- })
26
- res.json(company)
27
-
28
- } catch (errs) {
29
- res.error(errs)
13
+ async function update(req, res) {
14
+ try {
15
+ const update = await db.company.update({
16
+ query: req.params.cid,
17
+ data: req.body,
18
+ files: req.query.files ? req.files : undefined,
19
+ })
20
+ if (!update) {
21
+ throw new Error('Coudln\'t find the company to update')
30
22
  }
31
- },
23
+ const company = await db.company.findOne({
24
+ query: req.params.cid,
25
+ populate: db.company.loginPopulate(),
26
+ _privateData: true,
27
+ })
28
+ res.json(company)
32
29
 
33
- updateUser: async function(req, res) {
34
- try {
35
- const update = await db.user.update({
36
- query: req.params.uid,
37
- data: req.body,
38
- files: req.query.files ? req.files : undefined,
39
- })
40
- if (!update) {
41
- throw new Error('Coudln\'t find the user to update')
42
- }
43
- const user = await db.user.findOne({
44
- query: req.params.uid,
45
- _privateData: true,
46
- blacklist: ['company'], // don't return the company id
47
- })
48
- res.json(user)
30
+ } catch (errs) {
31
+ res.error(errs)
32
+ }
33
+ }
49
34
 
50
- } catch (errs) {
51
- res.error(errs)
35
+ async function updateUser(req, res) {
36
+ try {
37
+ const update = await db.user.update({
38
+ query: req.params.uid,
39
+ data: req.body,
40
+ files: req.query.files ? req.files : undefined,
41
+ })
42
+ if (!update) {
43
+ throw new Error('Coudln\'t find the user to update')
52
44
  }
53
- },
45
+ const user = await db.user.findOne({
46
+ query: req.params.uid,
47
+ _privateData: true,
48
+ blacklist: ['company'], // don't return the company id
49
+ })
50
+ res.json(user)
54
51
 
52
+ } catch (errs) {
53
+ res.error(errs)
54
+ }
55
55
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nitro-web",
3
- "version": "0.0.29",
3
+ "version": "0.0.31",
4
4
  "repository": "github:boycce/nitro-web",
5
5
  "homepage": "https://boycce.github.io/nitro-web/",
6
6
  "description": "Nitro is a battle-tested, modular base project to turbocharge your projects, styled using Tailwind 🚀",
package/server/index.js CHANGED
@@ -19,6 +19,6 @@ export { setupRouter } from './router.js'
19
19
  export { sendEmail } from './email/index.js'
20
20
 
21
21
  // Export api default controllers
22
- export { default as auth } from '../components/auth/auth.api.js'
22
+ export { default as auth, findUserFromProvider, signinAndGetState, userCreate } from '../components/auth/auth.api.js'
23
23
  export { default as settings } from '../components/settings/settings.api.js'
24
24
  export { default as stripe } from '../components/billing/stripe.api.js'
@@ -9,7 +9,7 @@ export default {
9
9
  email: { type: 'email', required: true, index: 'unique' },
10
10
  firstName: { type: 'string', required: true },
11
11
  lastName: { type: 'string' },
12
- password: { type: 'string', minLength: 6, required: true },
12
+ password: { type: 'string', minLength: 6 },
13
13
  resetToken: { type: 'string' },
14
14
  status: { type: 'string', default: 'active', enum: ['active', 'deleted', 'inactive'] },
15
15
  stripeCustomer: { type: 'any' },