Skip to content

Instantly share code, notes, and snippets.

View anteburazer's full-sized avatar
💭
Ride hard live free

Ante Burazer anteburazer

💭
Ride hard live free
View GitHub Profile
let baseUrl: string = this.configService.get(api).baseUrl;
@Injectable()
export class ConfigService {
private config: Object
private env: Object
constructor(private http: Http) {}
/**
* Loads the environment config file first. Reads the environment
{
"api": {
"baseUrl": "/api"
},
"debugging": true
}
"scripts": {
"start": "npm run pre-start & ng serve",
"pre-start": "node hooks/pre-start.js",
"pre-build": "node hooks/pre-build.js",
"my-custom-build": "npm run pre-build & ng build --prod --aot"
}
{ "env": "development" }
function setEnvironment(configPath, environment) {
fs.writeJson(configPath, {env: environment},
function (res) {
console.log('Environment variable set to ' + environment)
}
);
}
// Set environment variable to "production"
setEnvironment('./src/config/env.json', 'production');
const formDataMediaType = {
'Accept': 'application/json, text/plain, */*',
'content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
};
@POST("/products")
@Produces(MediaType.FORM_DATA)
@Headers(formDataMediaType)
@Adapter(CustomService.customAdapter)
@Injectable()
@DefaultHeaders({
'Accept': 'application/json',
'Content-Type': 'application/json'
})
export class ProductsApiClient extends HttpService {
@PUT("/products/{id}")
public updateProductById(@Path("id") id: number, @Body product: Product): Observable<any> { return null; };
}
@Effect()
doLogin$: Observable<Action> = this.actions$
.ofType(actions.ActionTypes.DO_LOGIN)
.map((action: actions.DoLoginAction) => action.payload)
.switchMap(state => {
return this.authApiClient.login(state)
.map(user => new actions.DoLoginSuccessAction(new User(user)))
.catch(error => of(new actions.DoLoginFailAction()));
});
export interface State {
products: fromProducts.State;
login: fromAuth.State;
}
const reducers = {
products: fromProducts.reducer,
login: fromAuth.reducer
};