sourcefuse / loopback4-starter

Loopback 4 starter application. Multi-tenant architecture supported. Authentication, Authorization, Soft deletes, environment vars, Audit logs, included.
MIT License
158 stars 59 forks source link

How to refresh explorer? #20

Closed sherif2011 closed 5 years ago

sherif2011 commented 5 years ago

Hello @samarpan-b ,

I am having troubles refreshing API explorer after making some changes to controllers. Some times I totally drop a controller, save and run, and still see end points there in API explorer. How can I refresh explorer?

I tried npm run clean then npm run build but that didn't help. Actually if I do that I lose all files in dist folder except for readme files and get the following error: Error: Cannot find module './dist' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15) at Function.Module._load (internal/modules/cjs/loader.js:562:25) at Module.require (internal/modules/cjs/loader.js:690:17) at require (internal/modules/cjs/helpers.js:25:18) at Object. (C:\Users\smankarious\Desktop\admin\index.js:1:21) at Module._compile (internal/modules/cjs/loader.js:776:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) at Function.Module._load (internal/modules/cjs/loader.js:585:3)

Any clue please?

For your reference, if needed here is my package.json file.

package_json.txt

samarpan-b commented 5 years ago

@sherif2011 Unfortunately, it's an issue with latest loopback/build version. We have raised a similar issue on loopback repo for the same. See this - https://github.com/strongloop/loopback-next/issues/3358. We need to wait for the solution to that or revert to older version down from major version 2.

sherif2011 commented 5 years ago

@samarpan-b Any work around just to build, should I revert to older version, build then upgrade to newer version?

samarpanB commented 5 years ago

Revert to @loopback/build version 1 for now. Don’t upgrade

sherif2011 commented 5 years ago

I moved back to 1.7.1 but issue is still there, I tried 1.0.0 but am getting a bunch of errors:

node_modules/loopback4-authentication/dist/keys.d.ts:3:26 - error TS7016: Could not find a declaration file for module 'passport'. 'C:/Users/smankarious/Desktop/admin/node_modules/passport/lib/index.js' implicitly has an 'any' type. Try npm install @types/passport if it exists or add a new declaration (.d.ts) file containing declare module 'passport';

3 import { Strategy } from 'passport';


node_modules/loopback4-authentication/dist/strategies/passport/passport-bearer/bearer-strategy-factory-provider.d.ts:2:33 - error TS7016: Could not find a declaration file for module 'passport-http-bearer'. 'C:/Users/smankarious/Desktop/admin/node_modules/passport-http-bearer/lib/index.js' implicitly has an 'any' type.
  Try `npm install @types/passport-http-bearer` if it exists or add a new declaration (.d.ts) file containing `declare module 'passport-http-bearer';`

2 import * as PassportBearer from 'passport-http-bearer';

node_modules/loopback4-authentication/dist/strategies/passport/passport-client-password/client-password-strategy-factory-provider.d.ts:2:41 - error TS7016: Could not find a declaration file for module 'passport-oauth2-client-password'. 'C:/Users/smankarious/Desktop/admin/node_modules/passport-oauth2-client-password/lib/index.js' implicitly has an 'any' type. Try npm install @types/passport-oauth2-client-password if it exists or add a new declaration (.d.ts) file containing declare module 'passport-oauth2-client-password';

2 import * as ClientPasswordStrategy from 'passport-oauth2-client-password';


node_modules/loopback4-authentication/dist/strategies/passport/passport-google-oauth2/google-auth-strategy-factory-provider.d.ts:2:33 - error TS7016: Could not find a declaration file for module 'passport-google-oauth20'. 'C:/Users/smankarious/Desktop/admin/node_modules/passport-google-oauth20/lib/index.js' implicitly has an 'any' type.
  Try `npm install @types/passport-google-oauth20` if it exists or add a new declaration (.d.ts) file containing `declare module 'passport-google-oauth20';`

2 import * as GoogleStrategy from 'passport-google-oauth20';

node_modules/loopback4-authentication/dist/strategies/passport/passport-local/local-password-strategy-factory-provider.d.ts:2:32 - error TS7016: Could not find a declaration file for module 'passport-local'. 'C:/Users/smankarious/Desktop/admin/node_modules/passport-local/lib/index.js' implicitly has an 'any' type. Try npm install @types/passport-local if it exists or add a new declaration (.d.ts) file containing declare module 'passport-local';

2 import * as PassportLocal from 'passport-local';


node_modules/loopback4-authentication/dist/strategies/passport/passport-resource-owner-password/oauth2-resource-owner-password-grant.d.ts:1:27 - error TS7016: Could not find a declaration file for module 'passport'. 'C:/Users/smankarious/Desktop/admin/node_modules/passport/lib/index.js' implicitly has an 'any' type.
  Try `npm install @types/passport` if it exists or add a new declaration (.d.ts) file containing `declare module 'passport';`

1 import * as passport from 'passport';

node_modules/loopback4-authentication/dist/strategies/types.d.ts:3:33 - error TS7016: Could not find a declaration file for module 'passport-google-oauth20'. 'C:/Users/smankarious/Desktop/admin/node_modules/passport-google-oauth20/lib/index.js' implicitly has an 'any' type. Try npm install @types/passport-google-oauth20 if it exists or add a new declaration (.d.ts) file containing declare module 'passport-google-oauth20';

3 import * as GoogleStrategy from 'passport-google-oauth20';



node_modules/loopback4-authentication/dist/strategy-adapter.d.ts:3:26 - error TS7016: Could not find a declaration file for module 'passport'. 'C:/Users/smankarious/Desktop/admin/node_modules/passport/lib/index.js' implicitly has an 'any' type.
  Try `npm install @types/passport` if it exists or add a new declaration (.d.ts) file containing `declare module 'passport';`

3 import { Strategy } from 'passport';
sherif2011 commented 5 years ago

Should I just follow along by install the above packages manually?

sherif2011 commented 5 years ago

Ok, I downgraded to 1.0.0, and installed missing packages, saved all and npm start.... controller is showing old stuff still: image

And here is my controller which should have only one end-point: import {post, param, requestBody} from '@loopback/rest'; import {UserRepository} from '../../repositories'; import {User, UserCredentials} from '../../models'; import {repository} from '@loopback/repository';

export class UserCredentialsController { constructor( @repository(UserRepository) protected userRepository: UserRepository, ) {}

@post('/users/{id}/credentials') async createAccount( @param.path.number('id') userId: typeof User.prototype.id, @requestBody() credentials: UserCredentials, ): Promise { return await this.userRepository.credentials(userId).create(credentials); } }

Please help!!

sherif2011 commented 5 years ago

It seems to be a bit random. Now it updated the explorer.